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

chrr
  • 320
  • 1
  • 4
  • 15
  • possible duplicate of [Parsing xml](http://stackoverflow.com/questions/3187819/parsing-xml) – Pekka Feb 16 '12 at 22:01

2 Answers2

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

roxes
  • 113
  • 7
0

jQuery Ajax includes support for xml. See example post.

Also, see here

Larry K
  • 47,808
  • 15
  • 87
  • 140