xml - 在nifi中使用EvaluateXpath

标签 xml xpath apache-nifi

我有这样的 xml 响应:

<Result xmlns="olineservice" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ResponseStatus>false</ResponseStatus>
<Error>
<ErrorCode>-7</ErrorCode>
<ErrorDescription>data  wasn't  found</ErrorDescription>
</Error>
</Result>

我想获取ErrorCode的值。我试过这个:

//Error[1]/text() 

但是 ErrorCode 属性似乎是 Nan

您能给我推荐任何解决方案吗?

最佳答案

具体获取错误代码:

//Error[1]/ErrorCode/text()

具体获取错误描述:

//Error[1]/ErrorDescription/text()

这些值都以这种方式读取为文本,因此您可以读取为数字:

//Error[1]/ErrorCode/number()

关于xml - 在nifi中使用EvaluateXpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45835324/

相关文章:

python xpath : Compare dates

javascript - 如何使用 xpath 克隆 SVG map

在 Apache nifi 中将两个模式合并为一个

html - 网络抓取的新手 - 是否可以使用路径定位 css 图像?

Java线程安全写入xml文件?

java - 将位图设置为具有特定高度的ImageView

java - SAX解析器,解析后新行被删除,我可以保留它们吗? ( )

apache-nifi - Zookeeper 对集群 Nifi 的推荐

apache-nifi - Apache Nifi - 使用 Kafka + 合并内容 + 放置 HDFS 以避免小文件

php - 解析并显示 xml 中的数据