0

I am pulling the following response back from a page via jQuery ajax request.

I have been struggling trying to write a nifty function to extract specific values from the data given a set of criteria.

For example I would like to call a function and pass in 2 params, "TYPE" (i.e ANALOG, DIGITAL etc) and INDEX which specifies the index in that section.

So for example func("ANALOG", 8) would return 2.2 etc

I have tried to achieve this looping through a json response but with little sucess

 <response>
<ANALOG>
    <VARIABLE>
        <INDEX>7</INDEX>
        <VALUE>4.8</VALUE>
    </VARIABLE>
    <VARIABLE>
        <INDEX>8</INDEX>
        <VALUE>2.2</VALUE>
    </VARIABLE>
    <VARIABLE>
        <INDEX>9</INDEX>
        <VALUE>89.2</VALUE>
    </VARIABLE>
</ANALOG>
<DIGITAL>
    <VARIABLE>
        <INDEX>1</INDEX>
        <VALUE>1</VALUE>
    </VARIABLE>
    <VARIABLE>
        <INDEX>2</INDEX>
        <VALUE>1</VALUE>
    </VARIABLE>
    <VARIABLE>
        <INDEX>3</INDEX>
        <VALUE>0</VALUE>
    </VARIABLE>
</DIGITAL>
<INTEGER>
    <VARIABLE>
        <INDEX>2</INDEX>
        <VALUE>1</VALUE>
    </VARIABLE>
    <VARIABLE>
        <INDEX>3</INDEX>
        <VALUE>12</VALUE>
    </VARIABLE>
    <VARIABLE>
        <INDEX>4</INDEX>
        <VALUE>21</VALUE>
    </VARIABLE>
</INTEGER>

Any ideas welcome

Thanks

1
  • possible duplicate of Parsing xml Commented Feb 16, 2012 at 22:01

2 Answers 2

1

I think you're having problem extracting the XML value, not sure if this would able to give you some basic understanding,

Read Parse and Display XML

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Kevin, all sorted now.
0

jQuery Ajax includes support for xml. See example post.

Also, see here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.