开发者

jQuery XML parsing - Get child nodes and attributes

开发者 https://www.devze.com 2023-04-12 11:27 出处:网络
I have an xml string that I\'m passing to a javascript function. var t = $(\'<?xml version=\"1.0\" ?><Messages><JCallB开发者_如何学JAVAack ProgramName=\"x\"><Value><![CDATA

I have an xml string that I'm passing to a javascript function.

var t = $('<?xml version="1.0" ?><Messages><JCallB开发者_如何学JAVAack ProgramName="x"><Value><![CDATA[top.closeCtrlLoading();]]></Value></JCallBack><RObject Type="E" Name="gH2ptObj_co_code" ChangeType="objProp" rowNum="" colNum=""><Property Name="value"><Value><![CDATA[]]></Value></Property></RObject></Messages>');

I was looking at this question to get the values of each of my nodes.

t.filter('Messages').each(function () {
  alert($(this).find('RObject').text());
});

Here is my fiddle

I would like to get all the information out of each node in RObject as well as the children nodes inside of Robject (i.e. Property and Value).

My fiddle isn't quite correct yet. Can someone please advise what I have to do to get this working?


You'll want to run $.parseXML() on your data before trying to process it.

Edit x2: See the updated, working, fiddle.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号