Reputation: 82231
I have made an ajax call which returns me some xml in my success function.something like this:
<grid row_count="39">
<item>
<id>343</id>
<publickey>e9a515f9-44ac-4af9-b4b2-c30dd366ac83</publickey>
<name><![CDATA[repeater dsds]]></name>
<description />
<subject />
<templatetype>16</templatetype>
<socialmediatype>0</socialmediatype>
<trackingmediaid />
<companyid>226</companyid>
<createdon>3/14/2013 12:15:03 PM</createdon>
<updatedon>
I want to get the value of row_count present in grid tag.i am not at all familiar with xml.any help would be great. Thanks...!!
Upvotes: 0
Views: 107
Reputation: 318162
If the dataType is set to xml, jQuery will parse it for you, otherwise run $.parseXML
and use DOM traversal methods the regular way:
var xml = $.parseXML(data_from_ajax);
var row_count = $(xml).filter('grid').attr('row_count');
In your string above neither item
nor grid
is properly closed, and that will cause issues if that is how the original string is as well. You also need to use either find()
or filter()
depending on where grid
occurs in the string ?
Upvotes: 2