XPATH 不工作 ns2:namespace 前缀未定义错误
XPATH not working ns2:namespace preifix not defined error
您好,我正在尝试使用 xpath /ns0:Start/ns0:Area/ns0:Test/ns0:Identifier/ns2:UniqueID 提取 UniqueID 的值,但它不起作用帮助我,我需要正常的 xpath 以及 MEL 命令
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Start xmlns:ns0="http://www.example.com/xmlns/9/Test">
<ns0:Area>
<ns0:Test>
<ns0:Identifier>
<ns2:UniqueID xmlns:ns2="http://www.example.com/xmlns/9/foundation">123456</ns2:UniqueID>
</ns0:Identifier>
</ns0:Test>
<ns0:Test>
<ns0:Identifier>
<ns2:ExternalOrderID xmlns:ns2="http://www.example.com/xmlns/9/foundation">external</ns2:ExternalOrderID>
</ns0:Identifier>
<ns0:Info>
<ns0:Status>st</ns0:Status>
</ns0:Info>
</ns0:Test>
</ns0:Area>
</ns0:Start>
<mulexml:namespace-manager includeConfigNamespaces="true">
<mulexml:namespace prefix="foo" uri="http://foo.com"/>
</mulexml:namespace-manager>
正如 Victor 所说,您需要使用 mulexml:namespace-manager
作为名称 space :-
尝试以下操作:-
<mulexml:namespace-manager includeConfigNamespaces="true">
<mulexml:namespace prefix="ns0" uri="http://www.example.com/xmlns/9/Test"/>
<mulexml:namespace prefix="ns2" uri="http://www.example.com/xmlns/9/foundation"/>
</mulexml:namespace-manager>
然后使用以下 Xpath 检索 UniqueID :- #[xpath('//ns0:Start/ns0:Area/ns0:Test/ns0:Identifier/ns2:UniqueID').text]
和外部订单ID:- #[xpath('//ns0:Start/ns0:Area/ns0:Test/ns0:Identifier/ns2:ExternalOrderID').text]
这会起作用:)
您好,我正在尝试使用 xpath /ns0:Start/ns0:Area/ns0:Test/ns0:Identifier/ns2:UniqueID 提取 UniqueID 的值,但它不起作用帮助我,我需要正常的 xpath 以及 MEL 命令
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Start xmlns:ns0="http://www.example.com/xmlns/9/Test">
<ns0:Area>
<ns0:Test>
<ns0:Identifier>
<ns2:UniqueID xmlns:ns2="http://www.example.com/xmlns/9/foundation">123456</ns2:UniqueID>
</ns0:Identifier>
</ns0:Test>
<ns0:Test>
<ns0:Identifier>
<ns2:ExternalOrderID xmlns:ns2="http://www.example.com/xmlns/9/foundation">external</ns2:ExternalOrderID>
</ns0:Identifier>
<ns0:Info>
<ns0:Status>st</ns0:Status>
</ns0:Info>
</ns0:Test>
</ns0:Area>
</ns0:Start>
<mulexml:namespace-manager includeConfigNamespaces="true">
<mulexml:namespace prefix="foo" uri="http://foo.com"/>
</mulexml:namespace-manager>
正如 Victor 所说,您需要使用 mulexml:namespace-manager
作为名称 space :-
尝试以下操作:-
<mulexml:namespace-manager includeConfigNamespaces="true">
<mulexml:namespace prefix="ns0" uri="http://www.example.com/xmlns/9/Test"/>
<mulexml:namespace prefix="ns2" uri="http://www.example.com/xmlns/9/foundation"/>
</mulexml:namespace-manager>
然后使用以下 Xpath 检索 UniqueID :- #[xpath('//ns0:Start/ns0:Area/ns0:Test/ns0:Identifier/ns2:UniqueID').text]
和外部订单ID:- #[xpath('//ns0:Start/ns0:Area/ns0:Test/ns0:Identifier/ns2:ExternalOrderID').text]
这会起作用:)