If I have an RSS newsfeed like this:
<?xml version="1.0" encoding="utf-8"?><!-- generator="whoc ares" -->
<rss version="0.92">
<channel>
<title>Websit e Name</title>
<link>http://www.websiteurl. com</link>
<description>De scription of website</description>
<lastbuilddate> Sun, 19 Sep 2004 04:34:52 +0000</lastbuilddate>
<docs>http://backend.userlan d.com/rss092</docs>
<item>
<title>1st Title</title>
<description>1s t Description</description>
<link>http://www.websiteurl. com/1stlink/</link>
</item>
<item>
<title>2nd Title</title>
<description>2n d Description</description>
<link>http://www.websiteurl. com/2ndlink/</link>
</item>
</channel>
</rss>
And the following code is used to parse that file/feed:
<?php
$feed = 'http://www.example.com/feed/rss/';
/* ...create and XML parser... */
$xml_parser = xml_parser_crea te();
/* ...open the feed and parse it... */
$fp = @fopen($feed, 'rb');
if (is_resource($f p)) {
xml_parse_into_ struct( $xml_parser, $fp, $vals, $index );
}
@fclose($fp);
/* ...free parser */
xml_parser_free ( $xml_parser );
?>
How do I extract the values from $xml_parser?
<?xml version="1.0" encoding="utf-8"?><!-- generator="whoc ares" -->
<rss version="0.92">
<channel>
<title>Websit e Name</title>
<link>http://www.websiteurl. com</link>
<description>De scription of website</description>
<lastbuilddate> Sun, 19 Sep 2004 04:34:52 +0000</lastbuilddate>
<docs>http://backend.userlan d.com/rss092</docs>
<item>
<title>1st Title</title>
<description>1s t Description</description>
<link>http://www.websiteurl. com/1stlink/</link>
</item>
<item>
<title>2nd Title</title>
<description>2n d Description</description>
<link>http://www.websiteurl. com/2ndlink/</link>
</item>
</channel>
</rss>
And the following code is used to parse that file/feed:
<?php
$feed = 'http://www.example.com/feed/rss/';
/* ...create and XML parser... */
$xml_parser = xml_parser_crea te();
/* ...open the feed and parse it... */
$fp = @fopen($feed, 'rb');
if (is_resource($f p)) {
xml_parse_into_ struct( $xml_parser, $fp, $vals, $index );
}
@fclose($fp);
/* ...free parser */
xml_parser_free ( $xml_parser );
?>
How do I extract the values from $xml_parser?
Comment