I need your help on the Namespaces for XMLStarlet. (never saw a library that badly explained) I have an XML file like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx version="2005-1" xml:lang="fr" xmlns="http://www.daisy.org/z3986/2005/ncx/">
<head>
<meta name="dtb:uid" content="9782721213747"/>
<meta name="dtb:depth" content="1"/>
<meta name="dtb:totalPageCount" content="0"/>
<meta name="dtb:maxPageNumber" content="0"/>
</head>
<docTitle>
<text>My text</text>
</docTitle>
<navMap>
<navPoint id="NavPoint-1" playOrder="1"><navLabel><text>Couverture</text></navLabel><content src="01_cover.html"/></navPoint>
And so on.
So now, my queries in XMLstarlet fail due to the presence of the namespaces.
xmlns="http://www.daisy.org/z3986/2005/ncx/"
I have read that you can use SED to remove the namespaces. Just like that:
cat Myfile.ncx | sed -e 's/ xmlns.*=".*"//g' | xmlstarlet ed -d "/ncx/navMap/navPoint[@playOrder='5']"
Which works just fine. Problem is, I need the namespaces and do not want to remove them.
Also, I have tried this:
xmlstarlet -N x="http://www.daisy.org/z3986/2005/ncx/" ed -d "/ncx/navMap/navPoint[@playOrder='5']" Myfile.ncx
which does not work. (also not understanding what means x in x="http..." I read some put "my" some put other values ... and there is no man page for this in the XMLStarlet pages)
Any idea how to use the XMLStarlet with this XML file and KEEP the namespaces in the output?
(I use XML starlet to remove some nodes I do not use. It's way safer to make it this way rather than using shell commands)
Huge thanks to whoever helps ;)