I've got a problem with my xml parser, this is the xml file:
<?xml version="1.0" encoding="UTF-8"?>
<root name="gf">
<node id="textone"/>
<node id="textwo"/>
<node id= "texthree" />
</root>
I use that code to parse the xml file:
<?php
$dom2 = new DOMDocument();
$dom2->load('doc.xml');
$xpath2 = new DOMXPath($dom2);
$result2 = $xpath2->query('/root[@name="gf"]/node1/@id');
$id2 = $result2->item(0)->nodeValue; //this contains the id that I must use
$result2= $xpath2->query('/root[@name="gf"]/node1[@id='. $id2.']');
$comp2 = $result2->item(0)->nodeValue;
?>
Why I got this error in the last row?? "Notice: Trying to get property of non-object" I've already used this code and when "id" it's a number it works, why it doesn't work when it's a string??