Code Comments
Programming Forum and web based access to our favorite programming groups.Charles Stricklin wrote:
> If I have an RSS newsfeed like this:
[...]
> And the following code is used to parse that file/feed:
[...]
> /* ...open the feed and parse it... */
> $fp = @fopen($feed, 'rb');
> if (is_resource($fp)) {
> xml_parse_into_struct( $xml_parser, $fp, $vals, $index );
> }
> @fclose($fp);
Read the manual closely and you will notice that the second argument of
xml_parse_into_struct() should be a string, not a resource.
The following would work better:
$file = file_get_contents($feed);
if ($file) {
xml_parse_into_struct( $xml_parser, $file, $vals, $index );
}
> How do I extract the values from $xml_parser?
Again, when you read the manual, you will notice that you don't extract the
values from the resource stored in $xml_parser, but that
xml_parse_into_struct() uses the last two arguments to create an array of
keys and values and an array of indexes which matches the positions of the
elements in the document.
Check the output of print_r() on both arrays to see what I mean.
Please read http://www.php.net/manual/en/ref.xml.php for more info and
examples.
JW
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.