giulio Posted January 21, 2013 Share Posted January 21, 2013 Hello! I was wondering if anyone can help me with attempting to load information on the following XML feed: http://www.tfl.gov.uk/tfl/syndication/feeds/cycle-hire/livecyclehireupdates.xml Into PHP. I only need information displayed for station ids 51,123 and 344. Any advice or help would be much appreciated. I've attached the code I've used to load up RSS feeds. I'm using iwebkit to develop an iPhone friendly website. Many thanks rss.php Link to comment https://forums.phpfreaks.com/topic/273444-extracting-information-from-xml/ Share on other sites More sharing options...
requinix Posted January 21, 2013 Share Posted January 21, 2013 Posting the code inline will get a lot more people looking at it. I don't see anything unusual in the XML so a quick example using SimpleXML would be $xml = new SimpleXMLElement("http://www.tfl.gov.uk/tfl/syndication/feeds/cycle-hire/livecyclehireupdates.xml", 0, true); foreach ($xml->station as $station) { echo "At {$station->name} there are {$station->nbBikes} bikes and {$station->nbEmptyDocks} of {$station->nbDocks} empty docks\n"; } [edit] You can target specific nodes with XPath. foreach ($xml->xpath("station[id=51 or id=123 or id=344]") as $station) { Link to comment https://forums.phpfreaks.com/topic/273444-extracting-information-from-xml/#findComment-1407342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.