danbliz Posted January 20, 2010 Share Posted January 20, 2010 I have a xml file with a value in it that I want to increment by one each time the page is viewed. Here is the xml file: <?xml version="1.0" encoding="utf-8"?> <thermometer> <goal goalNum="2553"><![CDATA[<b>2,553</b>]]></goal> <current currentNum="102" /> </thermometer> I need to increment currentNum by one. I keep trying different things, but can't seem to get it to work. Here is what I have: $dom = new DOMDocument(); $dom->load('tharmameter.xml'); $xpath = new DOMXPath($dom); $currentNumber = $xpath->query('thermometer/current/currentNum'); $newNum = $currentNumber + 1; $currentNum->nodeValue = $newNum; $dom->save('tharmameter.xml'); Can anyone tell me what I am doing wrong? Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.