【发布时间】:2022-01-03 02:15:32
【问题描述】:
我有一个 xml 文件,我需要检索节点“DocIDAutoNumerator”值,但如果提交的“ActivityTime”包含今天的日期(2021-08-11)我只需要获取它,如果节点“DocumentTypeValue”等于 1319。 我尝试了几个小时,但可以用我所做的来找回它。 这就是我所做的-
XPath
//Document[.//Field[Code[text()='DocumentTypeValue'] and Value[text()='1319']] and //ActivityTime[contains(text(),'2021-08-11')] ]//Fields[Field[Code="DocumentTypeValue"]] /Field[Code="DocIDAutoNumerator"]/Value
XML
<root>
<Document>
<Labels>
<Label>
<Fields>
<Field>
<Code>DocumentTypeValue</Code>
<Value>4008</Value>
</Field>
<Field>
<Code>DocIDAutoNumerator</Code>
<Value>123121</Value>
</Field>
</Fields>
</Label>
</Labels>
<ActivityTime>2021-08-11 </ActivityTime>
</Document>
<Document>
<Labels>
<Label>
<Fields>
<Field>
<Code>DocumentTypeValue</Code>
<Value>1319</Value>
</Field>
<Field>
<Code>DocIDAutoNumerator</Code>
<Value>21321</Value>
</Field>
</Fields>
</Label>
</Labels>
<ActivityTime>1993-08-11 </ActivityTime>
</Document>
</root>
【问题讨论】: