I have the following XML as a result from a webservice:
<response>
<type>SUCCESS</type>
<message/>
<data>
<rowset>
<head>
<!-- more tags here -->
</head>
<Row>
<cell Col="ID">102</cell>
<cell Col="SHIPMENT">1000036096</cell>
<cell Col="RFC">test</cell>
<cell Col="STATUS">SUCCESS</cell>
<cell Col="FIRST_PROCESSING">2014-08-27T15:48:08</cell>
<cell Col="LAST_PROCESSING">2014-08-27T15:57:59</cell>
<cell Col="MESSAGE"/>
<cell Col="RETRY_COUNT">2</cell>
</Row>
<Row>
<cell Col="ID">100</cell>
<cell Col="SHIPMENT">1000036157</cell>
<cell Col="RFC">test</cell>
<cell Col="STATUS">SUCCESS</cell>
<cell Col="FIRST_PROCESSING">2014-08-27T15:29:58</cell>
<cell Col="LAST_PROCESSING">2014-08-27T15:29:58</cell>
<cell Col="MESSAGE"/>
<cell Col="RETRY_COUNT">0</cell>
</Row>
</rowset>
</data>
</response>
I want to get the part of the XML under the data
tag. I need this part of the XML to pass to a javascript library that creates a grid based on this XML.
//webservice callback
onSuccess : function(xml){
var gridXML = $(xml).find("data").text();
},
The problem with this is that .text()
only keeps the tag values and removes the tags. How can I get everything under data
tag in string format?
EDIT: I tried .html()
as suggested and it indeed returns the nodes under data
. But the head
tag is removed.