I have trouble getting the value of the 'qt' child node of a selected 'item'.
XML
<cart>
<item>
<id>3</id>
<qt>101</qt>
<yourBid>88</yourBid>
</item>
</cart>
PHP
$xml = new DomDocument('1.0');
$xml->load('cart.xml');
$xpath = new DOMXPATH($xml);
$id = 3;
foreach($xpath->query("/cart/item[id='$id']") as $node)
{
// $qt=$node->qt;
// $qt=$node->children(0)->getName;
}
I've tried with these 2 methods but it doesn't seem to work.
$qt=$node->qt;
ERROR MESSAGE
Fatal error: Uncaught Error: Call to undefined method DOMElement::children() in C:\wamp64\www\test\test.php on line 12
Error: Call to undefined method DOMElement::children() in C:\wamp64\www\test\test.php on line 12
$qt=$node->children(0)->getName;
ERROR MESSAGE
Notice: Undefined property: DOMElement::$qt in C:\wamp64\www\test\test.php on line 11