我在尝试用XPaths获取多个XML时遇到了困难。
两个XML文件和XPaths如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<bq:ProcessB xmlns:bq="http://www.w3.com/xxml/1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:oa="http://www.openapplications.org/oagis/9" languageCode="en-US">
<oa:ApplicationArea xmlns:IOutput="com.wm.pkg.xslt.extension.IOutputMap">
<oa:Sender>
<oa:ID>A12345</oa:ID>
<oa:File>testing1.xml</oa:File>
<oa:ComID>BALON</oa:ComID>
<oa:RefID>1123</oa:RefID>
</oa:Sender>
<oa:MUSIC>TEST-0000-000-0000</oa:MUSIC>
</oa:ApplicationArea>
</bq:ProcessB>XPath:
record.bq.music = /bq:ProcessB/oa:ApplicationArea/oa:MUSIC
record.bq.fields.ID = /bq:ProcessB/oa:ApplicationArea/oa:Sender/oa:ID第二个XML和XPath:
<?xml version="1.0" encoding="UTF-8"?>
<bq:ProcessA xmlns:bq="http://www.w3.com/xxml/1" xmlns:oa="http://www.openapplications.org/oagis/9">
<bq:ProcessB languageCode="en-US" systemEnvironmentCode="QAS" releaseID="6.20">
<oa:ApplicationArea>
<oa:Sender>
<oa:ID>A12345</oa:ID>
<oa:File>testing1.xml</oa:File>
<oa:ComID>BALON</oa:ComID>
<oa:RefID>1123</oa:RefID>
</oa:Sender>
<oa:MUSIC>TEST-0000-000-0000</oa:MUSIC>
</oa:ApplicationArea>
</bq:ProcessB>
</bq:ProcessA>XPath:
record.bq.music = /bq:ProcessA/bq:ProcessB/oa:ApplicationArea/oa:MUSIC
record.bq.fields.ID = /bq:ProcessA/bq:ProcessB/oa:ApplicationArea/oa:Sender/oa:ID我试过这些通配符,但其中一个有效。我不能让两个xml都使用一个xpath表达式而不是两个。
*
//
axes - ancestor-or-self发布于 2019-03-20 18:56:53
两个XPath表达式
//oa:ApplicationArea/oa:MUSIC和
//oa:ApplicationArea/oa:Sender/oa:ID在定义了NS前缀bq的情况下,处理这两个XML文档。
https://stackoverflow.com/questions/55258486
复制相似问题