xml parsing (while loop question)
| From: | Kristopher Yates | Date: | Thu, 05 Sep 2002 20:04:50 +0000 |
| Subject: | xml parsing (while loop question) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-115348@lists.php.net to get a copy of this message | ||
Hi,
I have Marc Robards article on XML Parsing with PHP (wirelessdevnet.com).. which talks about parsing an XML FILE. My XML is from a remote server (used curl to get it back to PHP as a variable).
How do I change the following while to read from variable instead of file without getting these lame "XML error: junk after document element at line 1"?
while($data=fread($fp, 4096)){
if(!xml_parse($sml_parser, $data, feof($fp))){
die.........
}
}
What I tried was $data being the variable containing xml from remote host.. so I say
while($data){
}
which works but when it gets to the end it dies with:
XML error: junk after document element at line 1
Can anybody help me? Can anybody see? Sundays on the phone with monday.. sorry beatles flashback. I am not the walrus but I'm not a newbie either.. so very sorry for this newbie-esque question.
Kris