Hello,
Let’s say I have the following xml file
<rootnode>
<district id="1">
<detector name="dt1" id="20" type="up" />
<detector name="dt2" id="22" type="up" />
<detector name="dt1" id="25" type="up" />
</district>
</rootnode>
and I am accessing the detectors with name=“dt1” as follows
$dom = new DomDocument();
$dom->load("test.xml");
$xp = new domxpath($dom);
$data = $xp->query("//detector[@name='dt1']");
How do I access the various attributes in the nodes that I have selected? For example, how could I print out the name, id and type for each detector named dt1?