1

I'm trying to parse the site with folowing code.

<span id="ctl00_cphBody_resList_pnlResumes_rptResumes_ctl01_Label1" class="address">Somename, <nobr>Someage</nobr></span>

I'm parsing it this way

$fio=$text_specialty_next->find('span#ctl00_cphBody_resList_pnlResumes_rptResumes_ct'.$n.'_Label1');

But when I'm trying to print the result,

echo $fio->innertext;

There result is empty. What can cause this problem?

2
  • Now my sollution is like this. if ($n<10) { $nstr="0".$n; $fio=$text_specialty_next->find('span[id=ctl00_cphBody_resList_pnlResumes_rptResumes_ctl'.$nstr.'_Label1]'); } else { $fio=$text_specialty_next->find('span[id=ctl00_cphBody_resList_pnlResumes_rptResumes_ctl'.$n.'_Label1]'); } where $n=01, and it's increased. Commented Jun 12, 2012 at 18:11
  • I've fixed mistakes, and changed span#value to span[id=value], but it still doesn't work.=( What can I do now? Commented Jun 12, 2012 at 18:27

3 Answers 3

2

in find()

rptResumes_ct'.$n.'_Label1'

but it should be

rptResumes_ctl'.$n.'_Label1'

You miss an "l"

And what is the value of $n ?

Sign up to request clarification or add additional context in comments.

4 Comments

Oh, it's "l". I thought it was 1, lol. $n it's a variable, it has a value, that I substitute. Than's I'll try to fix solution.
:)) yes $n is a variable . I mean, what is it's value, how you use this ?
The value is 01 and it's increased in the loop. By the way, is it possible to make '01' value (not '1')?
@SergeyScopin , you can use sprintf() while declaring $n . Like this : $n = sprintf("%02d", 1); => $n = 01
1

Does $n="l01"? What parser are you using? In SimpleHTMLDom you need to use find(span[id=...]);

1 Comment

In the simpleHTMLDom Documentation it says to use element[attribute=value]. I am presuming you are using simpleHTMLDom. You also need to check the search string as @Eray says.
0

The problem was solved. $find->smth returns array, whick doesn't have innertext of course. I have to use foreach(find->smth as $someelement) to echo it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.