开发者

How do you parse xmlns:a="wm"?

Does anyone know how to parse this XML using JQuery or Javascript?

I tried using $.parseXML, but I'm not able to get each field.

<a:response xmlns:a="WM">
 <a:addresslist>
    <a:item>
      <a:DN>Doe, John </a:DN>
      <a:PH>+1 (111) 212-2381</a:PH>
      <a:OF>345 Ave, Floor 2</a:OF>
      <a:TL>Technical     Specialist</a:TL>
      <a:CP>Businessname</a:CP>
      <a:AN>JDoe</a:AN>
      <a:EM>John.Doe@testemail</a:EM>
    </a:i开发者_C百科tem>
 </a:addresslist>
</a:response>


Try this:

$(function(){
    var data = '<a:response xmlns:a="WM"> <a:addresslist>    <a:item>      <a:DN>Doe, John </a:DN>      <a:PH>+1 (111) 212-2381</a:PH>      <a:OF>345 Ave, Floor 2</a:OF>      <a:TL>Technical     Specialist</a:TL>      <a:CP>Businessname</a:CP>      <a:AN>JDoe</a:AN>      <a:EM>John.Doe@testemail</a:EM>    </a:item> </a:addresslist></a:response>';
    var xml = $($.parseXML(data));
    var nodes = xml.find("a\\:item *");
    $.each(nodes, function(a, b){
        alert($(b).text());
    });
});

Example @: http://jsfiddle.net/Cybernate/tf2z2/1/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜