I would like to get name of Tilt and its value 30. I am not able to get the value of Tilt. Let me know if you have any idea.
Thanks in advanced.
XML File:
<?xml version="1.0" encoding="UTF-8"?>
-<Physical>
<Catalog>
</Catalog>
-<Installed>
-<Equipment>
<Id>26</Id>
<Ref>Tew12</Ref>
-<Characteristic>
<CharacteristicName>Height</CharacteristicName>
<CharacteristicValue>160</CharacteristicValue>
</Characteristic>
-<Characteristic>
<CharacteristicName>Tilt</CharacteristicName>
<CharacteristicValue>30</CharacteristicValue>
</Equipment>
</Installed>
</Physical>
Expected Result:
Id 26
Tilt 30
Code:
/* For Id */
$Idquery = $xml->xpath("/Physical/Installed/Equipment/Id");
foreach ($Idquery as $Id)
{
print($Idquery->nodeValue);
}
/* For Tilt */
$XMLResults = $xml->xpath("/Physical/Installed/Equipment");
foreach($XMLResults as $item)
{
$Tilt = $item->xpath('//Characteristic[@CharacteristicName="Tilt"]');
print($Tilt->nodeValue);
}