【发布时间】:2018-01-04 04:35:26
【问题描述】:
我从其中一个 API 获取 XML 响应,我必须对其进行迭代并从中提取所需数据。当我第一次处理 XML 响应时,我遇到了一些困难。
以下是 XML 响应文件:
<feed xmlns:d="http://schemas.example.com/a" xmlns:m="http://schemas.example.com/a" xmlns="http://www.w3.org/2005/Atom" xml:base="http://demo_url:3000/url/example.xsodata/">
<title type="text">EMC_SR_NUMB</title>
<id>
http://demo_url:3000/url/example.xsodata/EMC_SR_NUMB
</id>
<author>
<name/>
</author>
<link rel="self" title="EMC_SR_NUMB" href="EMC_SR_NUMB"/>
<entry>
<id>
http://demo_url:3000/url/example.xsodata/EMC_SR_NUMB('204713171')
</id>
<title type="text"/>
<author>
<name/>
</author>
<link rel="self" title="EMC_SR_NUMB" href="EMC_SR_NUMB('204713171')"/>
<category term="infra.infrae.EMC_SR_NUMBType" scheme="http://schemas.microsoft.com/a"/>
<content type="application/xml">
<m:properties>
<d:key m:type="Abc.String">204713171</d:key>
<d:SR_NAME m:type="Abc.String">CLOV - 16RT</d:SR_NAME>
<d:REGION m:type="Abc.String">GENERAL</d:REGION>
</m:properties>
</content>
</entry>
<entry>
<id>
http://demo_url:3000/url/example.xsodata/EMC_SR_NUMB('204713172')
</id>
<title type="text"/>
<author>
<name/>
</author>
<link rel="self" title="EMC_SR_NUMB" href="EMC_SR_NUMB('204713172')"/>
<category term="infra.infrae.EMC_SR_NUMBType" scheme="http://schemas.microsoft.com/a"/>
<content type="application/xml">
<m:properties>
<d:key m:type="Abc.String">204713172</d:key>
<d:SR_NAME m:type="Abc.String">CLOV - 16RT</d:SR_NAME>
<d:REGION m:type="Abc.String">TRENDS</d:REGION>
</m:properties>
</content>
</entry>
</feed>
我必须提取以下数据:
1>d:key
2>d:SR_NAME
3>d:REGION
我正在使用 javascript 和 jquery。提前感谢您的帮助。
【问题讨论】:
标签: javascript jquery xml