How to get an XML value from a .xml file in Javascript?

maggieseoul

New Member
I have a file called 'status.xml' that contains the following:\[code\]<response><r1>~relay(1)~</r1><r2>~relay(2)~</r2><ct>~currentime~</ct><soc>~gaugeSOC~</soc><t1>25</t1></response>\[/code\]From an .htm page located in the same root directory as my status.xml file, I want to fetch the value at and have it parsed as an integer. I tried the following two methods unsuccessfully:\[code\]<script>...xmlDoc=loadXMLDoc("status.xml");gaugeSOC.setValue(xmlDoc.getElementsByTagName('t1'));</script>\[/code\]OR\[code\]<script>...var x = getXMLValue('status.xml', 't1');gaugeSOC.setValue(x);</script>\[/code\]Where gaugeSOC.setValue(int) receives an integer.What am I doing wrong?
 
Back
Top