html - php - plus one to xml node value -
html - php - plus one to xml node value -
this question has reply here:
a simple programme crud node , node values of xml file 3 answersi have xml file held on server below. have html file button when pressed must plus 1 (+1) 1 of xml node values.
im not clued on php help great. need simple script stored on server take in html request , add together 1 chosen xml node value.
<?xml version="1.0" encoding="utf-8"?> <object1> <value>10</value> </object1> <object2> <value>6</value> </object2>
try this:
$objectx = "2"; // value $_post or $_get ... $xmlfilename = 'my.xml'; // you're xml file $xmlfile = file_get_contents($xmlfilename); // saving xml contents in variable $objects = new simplexmlelement($xmlfile); $objectx = "object".$objectx; // object name $objects->$objectx->value++; // incrementing value $objects->asxml($xmlfilename); // saving xml echo $objects->$objectx->value; // echo value
you have add together <objects></objects>
xml file:
<?xml version="1.0" encoding="utf-8"?> <objects> <object1> <value>10</value> </object1> <object2> <value>6</value> </object2> </objects>
php html xml
Comments
Post a Comment