xmllint
XML parser and linter that supports XPath, a syntax for navigating XML trees. tldr-pages
On several platforms
Several platforms
Return all nodes (tags) with a specific name
xmllint --xpath "//node_name" source_file.xmlIdentifyReturn the contents of the first node with a specific name as a string
xmllint --xpath "string(//node_name)" source_file.xmlIdentifyReturn the href attribute of the second anchor element in an HTML file
xmllint --html --xpath "string(//a[2]/@href)" webpage.xhtmlIdentifyReturn human-readable (indented) XML from file
xmllint --format source_file.xmlIdentifyCheck that an XML file meets the requirements of its DOCTYPE declaration
xmllint --valid source_file.xmlIdentifyValidate XML against DTD schema hosted online
xmllint --dtdvalid url source_file.xmlIdentify