I have an XML doc with key and value pairs and I want to extract the value for a particular pair.
I tried:
var dat1 = xmlDoc.replace(/.*<d0>([^<]*)<\/d0>.*/, "$1");
The above gives me value for d0
in dat1
, but for subsequent data retrieval, it doesn't return correct values.
So, the first question is: What method can I use to extract values from an XML doc by using regexp (yes, I need to use regedt)?
Is the replace method used above correct?
Update: I have following xml string coming in:
<dataVal><d0>123</d0><d1>456</d1></dataVal>
Now, the inbuilt xml parsing methods works for me for mozilla and chrome but for IE it is not able to parse the string. Example, on IE it gets null if I use:
var dat1 = xmlDoc.getElementsByTagName('d0')[0].firstChild.nodeValue