PHP XML Question

sessinioxia

New Member
My PHP:\[code\]$url = '../build.xml';$xml = simplexml_load_file($url);foreach($xml->css as $css) { echo (string) $css->element['id']."{"; foreach($xml->css->element->csstag as $tag) { $temp = $tag->title.": ".$tag->value.";"; echo $temp; } echo "}";}\[/code\]My XML:\[code\]<root> <css> <element id="body"> <csstag><title>background-color</title><value>#FFF</value></csstag> <csstag><title>color</title><value>#333</value></csstag> <csstag><title>font-family</title><value>Verdana, Geneva, sans-serif</value></csstag> </element> <element id="#header"> <csstag><title>background-color</title><value>#444</value></csstag> <csstag><title>color</title><value>#FFF</value></csstag> <csstag><title>border-bottom</title><value>#333 5px solid</value></csstag> </element> <element id="#footer"> <csstag><title>background-color</title><value>#444</value></csstag> <csstag><title>color</title><value>#FFF</value></csstag> <csstag><title>border-top</title><value>#333 5px solid</value></csstag> </element> </css></root>\[/code\]I can't find what's wrong! The first issue is that the first foreach is showing just the first \[code\]<element>\[/code\] node, I know that's because I've told it to foreach each \[code\]<css>\[/code\] tag, but I couldn't think of any other way do echo the attribute of the \[code\]<element>\[/code\] nodes.The second thing is that the second foreach is echoing nothing back! Can anyone see the problem in the code? Thank you in advance!
 
Back
Top