Reputation: 160
I´m very fresh in XML files and would like to convert this command :
xpath -q -e "/ns2:softwareSystem/module/rootPath[not(@xsi:type)]/@name"\ file.xml
to this one xmllint --xpath
here is an example : https://github.com/apache/phoenix/pull/170/commits/16059876613ecb3a13b086adad9a8a861f04d1dc
Thanks for help
Upvotes: 0
Views: 211
Reputation: 5915
What you're looking for is :
xmllint --xpath "//*[local-name()='softwareSystem']/module/rootPath[not(@*[local-name()='type'])]/@name" file.xml
Note that using local-name()
is generally not recommended when you can declare namespaces in the application.
If you can, it's probably better to use xmlstarlet
since namespaces and namespace prefixes are better handled (you can use /ns2:softwareSystem
directly or /_:softwareSystem
).
EDIT : If you're dealing with a variable (for e.g. : variable="foo"
), you can use something like this :
xmllint --xpath "string(//*[local-name()='softwareSystem']/module[@name='"$variable"']/@id)" file.xml
Upvotes: 1