eb1 eb1 - 1 year ago 133
Javascript Question

xml nodeValue string interpreted as number

I'm parsing through an XML document using jquery, and seem to be having some problems with the

of an attribute. I've got the following element:

<chapter number="1" formattednumber="1." />

...where the attribute
is the string that will eventually be displayed in the UI. That's fine and well, until we look at:


Which returns a
instead of a string value (i.e., a
instead of a
-- interpreting the dot as a decimal point and removing it). Is there any way I can get the text value out of the attribute instead?

Answer Source

To get the attribute from an XML node as a string, you can use getAttribute()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download