K
kevinfairs
Quite a newbie to DOM and activex objects in javascript:
I have a requirement to write a piece of code which is capable of
reading in a node value from an xml file, performing some mathematical
functions on it, and then saving back to the same node.
I've got the node reading and the mathematical functions, I'm
struggling with the write back to xml. I have permissions on the
server to write to the file, so that's not an issue.
code so far is as thus:
//get xml file and get hit node
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("hit.xml")
//increment hit node by 1
hits = (xmlDoc.documentElement.childNodes.item(0).text)
hits = hits * 1
hits = hits + 1
document.write(hits)
XML file as thus:
<?xml version="1.0" ?>
<Counter>
<hits>0</hits>
</Counter>
any help would be greatly appreciated.
I have a requirement to write a piece of code which is capable of
reading in a node value from an xml file, performing some mathematical
functions on it, and then saving back to the same node.
I've got the node reading and the mathematical functions, I'm
struggling with the write back to xml. I have permissions on the
server to write to the file, so that's not an issue.
code so far is as thus:
//get xml file and get hit node
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("hit.xml")
//increment hit node by 1
hits = (xmlDoc.documentElement.childNodes.item(0).text)
hits = hits * 1
hits = hits + 1
document.write(hits)
XML file as thus:
<?xml version="1.0" ?>
<Counter>
<hits>0</hits>
</Counter>
any help would be greatly appreciated.