PHP outputing nested childnodes

Hayalet65

New Member
I am trying to output a xml file to an array thats then outputted to screen. The xml file loads I know it loads because as I can output entry > Id but I can not access its child nodes. I need the data located in.\[code\]content > s:organisationSummaycontent > s:organisationSummay > s:addresscontent > s:organisationSummay > s:geographicCoordinates\[/code\]how would I access the the data located in s:organisationSummay ,s:address, s:geographicCoordinates so I can getElementsByTagName for each items in that child node.\[code\]$doc2 = new DOMDocument();$url = 'http://v1.syndication.nhschoices.nhs.uk/organisations/'.$_POST['ServiceType'].'/postcode/'.$_POST['PostCode'].'.xml?apikey=??&range=50';echo $url;$doc2->load($url);$arrFeeds = array();foreach ($doc2->getElementsByTagName('entry') as $node) { echo $node->getElementsByTagName($content->'s:name'); $itemRSS = array ( 'PracticeName' => $organisationSummary->getElementsByTagName('s:name')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS);}\[/code\]\[code\]<?xml version="1.0" encoding="utf-8"?><feed xmlns:s="http://syndication.nhschoices.nhs.uk/services" xmlns="http://www.w3.org/2005/Atom"> <title type="text">NHS Choices - GP Practices Near Postcode - ls1- Within 50km</title> <id>http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/postcode/bd164jt?range=50</id> <rights type="text">? Crown Copyright 2009</rights> <updated>2012-07-06T10:24:46+01:00</updated> <category term="Search"/> <logo>http://www.nhs.uk/nhscwebservices/documents/logo1.jpg</logo> <author> <name>NHS Choices</name> <uri>http://www.nhs.uk</uri> <email>[email protected]</email> </author> <link rel="self" type="application/xml" title="NHS Choices - GP Practices Near Postcode - ;ls1 - Within 50km" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/postcode/ls1?apikey=??&range=50"/> <link rel="first" type="application/xml" title="first" length="1000" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/postcode/ls1?apikey=??&range=50&page=1"/> <link rel="next" type="application/xml" title="next" length="1000" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/postcode/Ls1?apikey=??&range=50&page=2"/> <link rel="last" type="application/xml" title="last" length="1000" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/postcode/LS1?apikey=??&range=50&page=10"/> <link rel="alternate" title="NHS Choices - Find and choose services - GP Practices" href="http://www.nhs.uk/ServiceDirectories/pages/ServiceSearch.aspx?ServiceType=GP"/> <s:SearchCoords>439300,411100</s:SearchCoords> <entry> <id>http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/1</id> <title type="text">Medical Practice</title> <updated>2012-07-06T09:24:46Z</updated> <link rel="self" title="Medical Practice" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/1?apikey=??"/> <link rel="alternate" title="Medical Practice" href="http://www.nhs.uk/ServiceDirectories/Pages/GP.aspx?pid=1"/> <content type="application/xml"> <s:organisationSummary> <s:name>Medical Practice</s:name> <s:address> <s:addressLine>Health Care Centre</s:addressLine> <s:addressLine>2</s:addressLine> <s:addressLine>Town</s:addressLine> <s:addressLine>Yorkshire</s:addressLine> <s:postcode>?</s:postcode> </s:address> <s:contact type="General"> <s:telephone>5558383</s:telephone> </s:contact> <s:geographicCoordinates> <s:northing>438880</s:northing> <s:easting>411444</s:easting> <s:longitude>-1.82821202227791</s:longitude> <s:latitude>53.996218047559</s:latitude> </s:geographicCoordinates> <s:Distance>0.5</s:Distance> </s:organisationSummary> </content> </entry> <entry> <id>http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/2</id> <title type="text">Surgery</title> <updated>2012-07-06T09:24:46Z</updated> <link rel="self" title="Surgery" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/1?apikey=??"/> <link rel="alternate" title="Surgery" href="http://www.nhs.uk/ServiceDirectories/Pages/GP.aspx?pid=2"/> <content type="application/xml"> <s:organisationSummary> <s:name>Surgery</s:name> <s:address> <s:addressLine>Healthcare Centre</s:addressLine> <s:addressLine>Kings</s:addressLine> <s:addressLine>Town</s:addressLine> <s:postcode>?</s:postcode> </s:address> <s:contact type="General"> <s:telephone>555555</s:telephone> <s:email>Email</s:email> </s:contact> <s:geographicCoordinates> <s:northing>78421</s:northing> <s:easting>484100</s:easting> <s:longitude>-1.828987402220691</s:longitude> <s:latitude>53.987218047559</s:latitude> </s:geographicCoordinates> <s:Distance>0.5</s:Distance> </s:organisationSummary> </content> </entry></feed>\[/code\]
 
Back
Top