我有如下所示的xml数据,我希望按名称获取localAttribtes标签' rs'在我的EvaluateXpath处理器中,我在我的EvaluateXpath处理器//localAttributes/*[@name='rs']/name()
中尝试了这个表达式,但我没有得到" rs"标签值:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<service>
<localAttributes name="rs">
<start>2017-09-07</start>
<startDate>2017-02-02</startDate>
<endDate>2017-03-02</endDate>
<runAs>true</runAs>
<patch>this is patch</patch>
<makeVersion>1</makeVersion>
</localAttributes>
<localAttributes name="ns">
<start>2017-09-07</start>
<startDate>2017-02-02</startDate>
<endDate>2017-03-02</endDate>
<runAs>true</runAs>
<patch>this is patch</patch>
<makeVersion>1</makeVersion>
</localAttributes>
</service>
答案 0 :(得分:1)
对于这种情况,正确的xpath是:
//localAttributes[@name='rs']/name()
但评估name()
非常奇怪,因为它会返回标记名称并且您事先知道标记名称 - localAttributes
如果您希望获得patch
的{{1}}标记值localAttributes
,其属性@name
等于'rs'
:
//localAttributes[@name='rs']/patch