3dhomejoe Posted July 24, 2009 Share Posted July 24, 2009 Hello,Ive got this xml document that gets updated every 48 hours and Im trying to make it display in a nice format for a website and the code that im using does not display all of it.My code <?php$xml = simplexml_load_file("myguild.xml");echo $xml->getName() . "<br />";foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; }?> and what it spits out is guilddetails:members:and this is the xml file, sorry the formatting got messed up<guild>−<details><id>2</id><name>Testname</name><server>Testserver</server></details>−<members>−<member><id>328</id><name> testmember </name><guildRank> Leader </guildRank><level> 56 </level><class> Templar </class><artisanClass> Weaponsmith </artisanClass><artisanLevel> 45 </artisanLevel><secondaryTradeskillClass> none </secondaryTradeskillClass><secondaryTradeskillLevel> 0 </secondaryTradeskillLevel></member></guild> Can anyone help me please?Thanks3dhomejoe Link to comment Share on other sites More sharing options...
boen_robot Posted July 24, 2009 Share Posted July 24, 2009 I think the problem is that echo-ing an element doesn't give you the text contents of all of its descendats.Either loop over the child's children, or use asXML(), like: foreach($xml->children() as $child) { echo $child->getName() . ": " . $child->asXML() . "<br />"; } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.