Thanks for devoting time. I am very new in php like an Infant.
I have a Xml file counter.xml like.
<?xml version="1.0"?>
<countIt>
<number>50</number></countIt>
I can read this file By SimpleXML as follows:
$content=simplexml_load_file("counter.xml");
$addid=$content->countIt->number;
Now I want to read this value (number---> id i.e. 55) after some operations like increment by 1, I want to save this new value of the node in file too. that means the new value must reflect into xml file.
I am stuck with this problem. I tried DOM but I got only help to create a new Xml File.
Please Help
SOLUTION:
<?php
$domObj= new DOMDocument();
$domObj->load("counter.xml");
$value= $domObj->getElementsByTagName("countIt");
$newVal = 0 ;
foreach( $value as $val)
{
$ints = $val->getElementsByTagName("number");
$intVal = $ints->item(0)->nodeValue;
$newVal = $intVal+1;
$domObj->getElementsByTagName("number")->item(0)->nodeValue = $newVal;
$domObj->save('counter.xml');
}
?>