0

I have this XML file called payload.xml:

<Remoting><Response>
<Controller id="c">
<Messages/>
<StructData name="Root">
    <F name="@ErrorOccured"/>
    <F name="@TransitionErrorOccurred"/>
    <List name="DataList" aspect="Delete"/>
    <List name="DataList" aspect="New">
        <Item name="001">
            <F name="CreationDateTime" >2012/04/26</F>
            <F name="ProductDescription" />
        </Item>
        <Item name="01F">
            <F name="CreationDateTime" >2012/08/09</F>
            <F name="ProductDescription" >Smartphone 16GB</F>
        </Item>                 
        <Header name="@tableSize">316 </Header>
    </List>
</StructData>
<Events>
    <Event event="$Core" operation="$AddRow" path="/Root/DataList"/>
</Events>
</Controller>
</Response></Remoting>

And I need to extract this XML from it:

<Item name="001">
    <F name="CreationDateTime" >2012/04/26</F>
    <F name="ProductDescription" />
</Item>
<Item name="01F">
    <F name="CreationDateTime" >2012/08/09</F>
    <F name="ProductDescription" >Smartphone 16GB</F>
</Item> 

My first step is:

jQuery.get("payload.xml", function(result){ 
    obj = $(result).find('Response').find('Controller').find('StructData');})

When I check inside the debugger I don't see any XML inside obj.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Tintin
  • 2,853
  • 6
  • 42
  • 74

2 Answers2

0

Try lowercasing your tags.

jQuery.get("payload.xml", function(result){ 
    obj = $(result).find('response').find('controller').find('structdata');})

If that doesn't work, try this

Nate Higgins
  • 2,104
  • 16
  • 21
0
$('Item', result).each(function(){
    $('F',this).text()
});
Thyago Quintas
  • 669
  • 2
  • 7
  • 12