Ignore Namespaces in XPath Query
e.g. Query for all xxx
nodes ignoring their namespace:
xmllint --xpath '//*[local-name()="xxx"]' input.xml
Tip
|
An example parsing URLs from a sitemap XML. The URLs are located in //url/loc where all nodes are bound to the namespace The following query ignores the namespace
|
Pretty Print XML in the Console using xmllint
echo '<blogs><blog url="https://www.hascode.com/">hasCode.com</blog></blogs>' | xmllint --format -
<?xml version="1.0"?>
<blogs>
<blog url="https://www.hascode.com/">hasCode.com</blog>
</blogs>
XSLT Strip Namespaces for Output
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://foo"
xmlns:bar="http://bar"
exclude-result-prefixes="foo bar">
Extract Nodes from XML via XPath in the console
xmllint --format --xpath '//plugin/name/text()' application.xml