get hold of node from xml in jquery

44 Views Asked by At

If I have the following XML:

<?xml version="1.0" encoding="utf-8"?>
<response>
    <status>SUCCESS</status>
    <result>
        <message>
            <field>
                <name>referenceNumber</name>
                <type>string</type>
                <required>true</required>
                <max>8</max>
                <min>0</min>
                <decimal_places>0</decimal_places>
            </field> ...

Is there a way to get the value for response/result/message? I know I can use a find("message") but if there are more than 1 message node then it doesn't work. I would like to know if there is a way to get to a particular node without 'guessing' if you know what I mean.

Thanks

1

There are 1 best solutions below

0
On

you want to use find().each('message)` http://api.jquery.com/jQuery.each/ kinda like

`$(xml).find("listing").each(function (){ // Do stuff. });