我想提取“output元素”的名称空间(-> http://Customer_LIB/bo/getCustomer/v1
<?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.0表达式来检查命名空间 “”在xml中使用。
使用此选项:
xmlstarlet sel -t -v '//result/namespace::*[2]' file
或
xmlstarlet sel -t -v '//result/namespace::*[contains(name(), "v1")]' file
http://Customer_LIB/bo/getCustomer/v