October 19, 201214 yr I'd like to use some data from an xml feed but I don't know how to travel through the tree structure. For each [item], I want to get the title, link, pubDate and description. The only way I could think of is using a number of nested foreach loops, but is there a better way? Thanks Below is an extract of the feed SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement Object ( [title] => Intelligent Travel [link] => http://intelligenttravel.nationalgeographic.com [description] => Cultural, Authentic & Sustainable [lastBuildDate] => Fri, 12 Oct 2012 18:42:06 +0000 [language] => en [generator] => http://wordpress.org/?v=3.3.3 [item] => Array ( [0] => SimpleXMLElement Object ( [title] => How to Shoot the Milky Way…On Easter Island [link] => http://intelligenttravel.nationalgeographic.com/2012/10/19/how-to-shoot-the-milky-way-on-easter-island/ [comments] => http://intelligenttravel.nationalgeographic.com/2012/10/19/how-to-shoot-the-milky-way-on-easter-island/#comments [pubDate] => Fri, 19 Oct 2012 16:04:13 +0000 [category] => Array ( [0] => SimpleXMLElement Object ( ) [1] => SimpleXMLElement Object ( ) [2] => SimpleXMLElement Object ( ) [3] => SimpleXMLElement Object ( ) ) [guid] => http://intelligenttravel.nationalgeographic.com/?p=35333 [description] => SimpleXMLElement Object ( ) ) [1] => SimpleXMLElement Object ( [title] => #FriFotos: Sit Down [link] => http://intelligenttravel.nationalgeographic.com/2012/10/19/frifotos-sit-down/ [comments] => http://intelligenttravel.nationalgeographic.com/2012/10/19/frifotos-sit-down/#comments [pubDate] => Fri, 19 Oct 2012 15:06:35 +0000 [category] => Array ( [0] => SimpleXMLElement Object ( ) [1] => SimpleXMLElement Object ( ) [2] => SimpleXMLElement Object ( ) [3] => SimpleXMLElement Object ( ) ) [guid] => http://intelligenttravel.nationalgeographic.com/?p=35345 [description] => SimpleXMLElement Object ( ) ) [2] => SimpleXMLElement Object ( [title] => Issue Insider: On Newsstands Now [link] => http://intelligenttravel.nationalgeographic.com/2012/10/18/issue-insider-on-newsstands-now/ [comments] => http://intelligenttravel.nationalgeographic.com/2012/10/18/issue-insider-on-newsstands-now/#comments [pubDate] => Thu, 18 Oct 2012 18:58:20 +0000 [category] => Array ( [0] => SimpleXMLElement Object ( ) [1] => SimpleXMLElement Object ( ) [2] => SimpleXMLElement Object ( ) [3] => SimpleXMLElement Object ( ) [guid] => http://intelligenttravel.nationalgeographic.com/?p=35305 [description] => SimpleXMLElement Object ( ) )
Create an account or sign in to comment