简体   繁体   English

如何在JavaScript中解析此xml?

[英]How can i parse this xml in javascript?

I need to parse in JavaScript an XML received from a REST webservice, with the format below, and put the information in a grid to show it on a web page. 我需要在JavaScript中解析从REST Web服务接收到的XML(格式如下),并将信息放入网格中以在网页上显示。 I look for a few examples, but, this format of XML is not the typical... Can someone help me please? 我寻找一些示例,但是XML的这种格式不是典型的...有人可以帮我吗? Only need a point to start.... 只需要一点就可以开始。

Many thanks! 非常感谢!

<root tablename="center">
  <row>
    <row_attribute name="cod">1100</row_attribute>
    <row_attribute name="nom">name1</row_attribute>
    <row_attribute name="cod2">TGN</row_attribute>
  </row>
  <row>
    <row_attribute name="cod">1200</row_attribute>
    <row_attribute name="nom">name2</row_attribute>
    <row_attribute name="cod2">TGT</row_attribute>
  </row>
</root>

You can use jQuery.parseXML for this. 您可以为此使用jQuery.parseXML It uses the underlying browser XML parser and gives you back an object that can be searched using jQuery methods. 它使用基础浏览器XML解析器,并为您提供可以使用jQuery方法搜索的对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM