Reputation: 3099
I have the following xml:
<Order>
<size width="16.5" height="19.5">
<width>16.5</width>
<height>19.5</height>
</size>
...
</Order>
I have tried the following to get the value of width/height:
width = parseFloat(doc.getElementsByTagName('width')[0].innerHTML);
height = parseFloat(doc.getElementsByTagName('height')[0].innerHTML);
However in the default Android browser and IE, I get the following when I alert the width: NaN. This code works fine in Chrome.
Upvotes: 1
Views: 39
Reputation: 193271
Since you have XML, not just HTML you should use childNodes
and nodeValue
:
width = parseFloat(doc.getElementsByTagName('width')[0].childNodes[0].nodeValue);
Upvotes: 1