首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从五旬节中的循环节点中提取XML节点值?

如何从五旬节中的循环节点中提取XML节点值?
EN

Stack Overflow用户
提问于 2015-02-05 16:09:48
回答 1查看 6.2K关注 0票数 1

我有一个XML在下面提到的格式。我正在使用五旬节中的Get XML来解析这一点。但是我无法得到正确的路径来得到所有的值。我想要'custom-attributes'.的所有值

它只给了我“性”的第一个属性.i.e的值。有谁能帮我得到其他custom-attributes.的值吗?

我已将“LoopXpath”设置为:- /names/name

在按“Get字段”之后,在“字段”选项卡中按下。我将自动在字段选项卡中获得自定义属性xpath,如下所述:-并且它只给出了'sex‘的值。

代码语言:javascript
复制
Name             |Xpath                                |Element     |  ResultType   |Type 
----------------------------------------------------------------------------------------------
custom-attributes |custom-attributes/custom-attribute  |Node         |Value of      |String



<names>
    <name>
      <firstname>ABCDEH</firstname>
      <lastname>JKLAM</lastname>
      <custom-attributes>
        <custom-attribute attribute-id="sex">male</custom-attribute>
        <custom-attribute attribute-id="height">169</custom-attribute>
        <custom-attribute attribute-id="weight">78</custom-attribute>
        <custom-attribute attribute-id="dateofbirth">09/09/1990</custom-attribute>
        <custom-attribute attribute-id="occupation">engineer</custom-attribute>
      </custom-attributes>
    </name>
  </names>

最后,我想要一排,如下所述:

代码语言:javascript
复制
firstname lastname   sex    height    weight   dateofbirth   occupation

ABCDEH    JKLAM      male    160        78      09/09/1990    engineer

有人能帮我一下吗

EN

回答 1

Stack Overflow用户

发布于 2015-02-05 18:22:04

我不知道你在代码中做了什么。首先,在步骤的“循环XPATH”设置部分中,定义父节点路径,而不是路径(如上文所述),如下所示:

代码语言:javascript
复制
/names/name/custom-attributes//*

其次,当您获得字段属性(即"custom-attribute",)时,需要将XPATH指定为'.‘(点)。这将执行属性值的递归。检查下面的图像:

最后,您将获得递归数据如下:

我在这里中放置了一个示例代码。请查一下,以供参考。

希望它有帮助:)

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28348709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档