I got an XML-File that Looks like this:
<?XML version="1.0" encoding="UTF-8"?>
<test:start xmlns:test="http://www.test.de" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<test:uebertragung art="OFFLINE" version="1.0.0"></test:uebertragung>
<test:object>
<test:objectnr>5</test:objectnr>
<test:objectview>
<test:geo>
<test:lat>12</test:lat>
<test:long>30</test:long>
</test:geo>
<test:objectcategorie>5</test:objectcategorie>
<test:geo>
<test:lat>11</test:lat>
<test:long>30</test:long>
</test:geo>
<test:objectcategorie>8</test:objectcategorie>
<test:geo>
<test:lat>16</test:lat>
<test:long>30</test:long>
</test:geo>
<test:objectcategorie>2</test:objectcategorie>
<test:geo>
<test:lat>14</test:lat>
<test:long>35</test:long>
</test:geo>
<test:objectcategorie>14</test:objectcategorie>
</test:objectview>
</test:object>
</test:start>
Now I want to parse this file in php. I got the following code which show me only the first object:
$xmlDoc->load("test.xml");
$x = $xmlDoc->documentElement;
$x = $x->childNodes[1];
$x = $x->childNodes[1];
foreach ($x->childNodes AS $item) {
print $item->nodeName . " = " . $item->nodeValue . "<br>";
}
Can somebody explain me a easier way to parse this XML-File. I want to show only the "test:lat" from all "objectsviews" and the "objectcategorie".