Xml 获取命名空间uri的xpath表达式
我想提取以下xml的“output元素”(->)的名称空间:Xml 获取命名空间uri的xpath表达式,xml,xpath,Xml,Xpath,我想提取以下xml的“output元素”(->)的名称空间: <?xml version="1.0" encoding="UTF-8"?> <result xsi:type="cu:getCustomerResponseMsg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cu="wsdl.http://Customer_LIB/Customer" xmlns:cu_1="http://Customer
<?xml version="1.0" encoding="UTF-8"?>
<result xsi:type="cu:getCustomerResponseMsg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cu="wsdl.http://Customer_LIB/Customer" xmlns:cu_1="http://Customer_LIB/Customer" xmlns:v1="http://Customer_LIB/bo/getCustomer/v1">
<cu_1:getCustomerResponse>
<output xsi:type="v1:GetCustomerResponse">
<firstName>Hans</firstName>
<lastName>Moser</lastName>
</output>
</cu_1:getCustomerResponse>
</result>
汉斯
莫瑟
有人有主意吗。我已经尝试过不同的表达方式。请考虑我只能使用XPath 1进行提取。非常感谢
有一个xpath 1.0表达式来检查xml中是否使用了名称空间“”,也就足够了 使用以下命令:
xmlstarlet sel -t -v '//result/namespace::*[2]' file
或
输出
是否还可以检查xml是否包含值为“”的命名空间,我尝试使用以下xpath值“//result/namespace::*[contains(namespace-uri(),“v1”)]”,但失败了。
xmlstarlet sel -t -v '//result/namespace::*[contains(name(), "v1")]' file
http://Customer_LIB/bo/getCustomer/v