R
richard.morey
Hi --
I am trying my first attempt at parsing XML via JavaScript. I currently
have this code:
str =
"<RESPONSE><RESULT>SUCCESS</RESULT><SECURITY>10</SECURITY></RESPONSE>"
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.loadXML(str);
xmlObj = xmlDoc.documentElement;
I am getting the values for "RESULT" and "SECURITY" as below:
alert('xmlObj.childNodes(0).nodeName =
'+xmlObj.childNodes(0).nodeName)
alert('xmlObj.childNodes(0).text = '+xmlObj.childNodes(0).text)
alert('xmlObj.childNodes(1).nodeName =
'+xmlObj.childNodes(1).nodeName)
alert('xmlObj.childNodes(1).text = '+xmlObj.childNodes(1).text)
but I would like to be able to get the value for each field without
having to iterate through each child. Additionally, I would like my
code to be cross-browser compliant and from what I understand the
"text" property is only available on IE. When I try using "nodeValue"
it is always null.
Any insight would be greatly appreciated!
Rich
I am trying my first attempt at parsing XML via JavaScript. I currently
have this code:
str =
"<RESPONSE><RESULT>SUCCESS</RESULT><SECURITY>10</SECURITY></RESPONSE>"
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.loadXML(str);
xmlObj = xmlDoc.documentElement;
I am getting the values for "RESULT" and "SECURITY" as below:
alert('xmlObj.childNodes(0).nodeName =
'+xmlObj.childNodes(0).nodeName)
alert('xmlObj.childNodes(0).text = '+xmlObj.childNodes(0).text)
alert('xmlObj.childNodes(1).nodeName =
'+xmlObj.childNodes(1).nodeName)
alert('xmlObj.childNodes(1).text = '+xmlObj.childNodes(1).text)
but I would like to be able to get the value for each field without
having to iterate through each child. Additionally, I would like my
code to be cross-browser compliant and from what I understand the
"text" property is only available on IE. When I try using "nodeValue"
it is always null.
Any insight would be greatly appreciated!
Rich