I have a shopping catalog with a button at the end of the each row to add the item to a shopping cart.i need to increment the "Quantity on hold(IqtyOH)" by one each time the user press the add button.I need to modify the xml document according to that.
here is my xml file just to get and idea.
<items>
<item>
<IId>1</IId>
<Iname>samsung</Iname>
<Iprice>360</Iprice>
<IqtyAv>9</IqtyAv>
<IqtyOH>0</IqtyOH>
<IqtySold>0</IqtySold>
<ItemDesc>Galaxy</ItemDesc>
</item>
<item>
<IId>2</IId>
<Iname>sony</Iname>
<Iprice>1200</Iprice>
<IqtyAv>12</IqtyAv>
<IqtyOH>0</IqtyOH>
<IqtySold>0</IqtySold>
<ItemDesc>vaio</ItemDesc>
</item>
</items>
I m trying to use xpath to retrieve the information from the xml file but its no use.Something is wrong. This is the code that I'm working on.
$dom = new DOMDocument;
$dom->loadXML(file_get_contents($xmlFile));
$xpath = new DOMXPath($dom);
$nodes = $xpath->query("//item[IID='$IId']/IqtyOH");
$node = $nodes->item(0)->nodeValue;
$node++;
$node->nodeValue = $node;
$dom->saveXML();