我一直在尝试通过XPath获取多个XML。
两个XML文件和XPath如下:
<?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
答案 0 :(得分:1)
两个XPath表达式
//oa:ApplicationArea/oa:MUSIC
和
//oa:ApplicationArea/oa:Sender/oa:ID
在定义了NS前缀bq
的情况下,在两个XML文档上进行工作。