kbrice Posted June 9, 2009 Share Posted June 9, 2009 I'm using Kevin Yank PHP Parsing Method from http://www.sitepoint.com/article/php-xml-parsing-rss-1-0/4/. But using my xml file below I can't seem to retrieve the URL from the link tag. Can anyone help? Part of my php code: function startElement($parser, $tagName, $attrs) { if ($this->insideitem) { $this->tag = $tagName; $this->attr = $attrs; } elseif ($tagName == "ITEM") { $this->insideitem = true; } } function endElement($parser, $tagName) { if ($tagName == "ITEM") { printf("<p><b><a href='%s'>%s</a></b></p>", trim($attrs['link']),htmlspecialchars(trim($this->title))); printf("<p>%s</p>", htmlspecialchars(trim($this->description))); $this->title = ""; $this->updated = ""; $this->description = ""; $this->link = ""; $this->insideitem = false; } } Example of my XML file from an atom RSS Feed: <item> <title type="html">...</title> <link rel="alternate" type="text/html" href="http://www.mydomain.com/nyc-technology/" /> <description>...</description> <updated>...</updated> </item> Link to comment https://forums.phpfreaks.com/topic/161537-php-parsing-xml-with-attributes-using-kevin-yank-php-parsing-method/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.