Load XML in php

Keepaitulteme

New Member
I have a SimpleXMLElement Object that I want to import with PHP.But it only loop through the first row in the XML file.I also want to show the specific columm with $item->columm1 instead of show the whole row whith all it's values .\[code\]$url = 'file.xml';$sxml = simplexml_load_file($url);foreach($sxml->Departure->attributes() as $item){ echo $item;}\[/code\]EDIT: Here is the output, notice that I have edit the orginal values with text1, text2.\[code\]SimpleXMLElement Object ( [Departure] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [name] => text1 [type] => text2 [stop] => text3 [time] => text4 [date] => text4 [direction] => text5 )\[/code\]EDIT2: Output->\[code\]object(SimpleXMLElement)#4 (2) { ["@attributes"]=> array(6) { ["name"]=> string(6) "text1" ["type"]=> string(3) "text2" ["stop"]=> string(12) "text3" ["time"]=> string(5) "text4" ["date"]=> string(8) "text5" ["direction"]=> string(10) "text6" } ["JourneyDetailRef"]=> object(SimpleXMLElement)#5 (1) { ["@attributes"]=> array(1) { ["ref"]=> string(125) "text7" } } } \[/code\]EDIT3: Output->\[code\] object(SimpleXMLElement)#7 (1) { [0]=> string(6) "text1" } object(SimpleXMLElement)#8 (1) { [0]=> string(3) "text2" } object(SimpleXMLElement)#7 (1) { [0]=> string(12) "text3" } object(SimpleXMLElement)#8 (1) { [0]=> string(5) "text4" } object(SimpleXMLElement)#7 (1) { [0]=> string(8) "text5" } object(SimpleXMLElement)#8 (1) { [0]=> string(10) "text6" } \[/code\]
 
Back
Top