I have content in the XML node <content type='html'> which uses the HTML entities < and > for < and > , i.e. in input.xml:
<?xml version='1.0' encoding='utf-8'?> <feed xmlns='http://www.w3.org/2005/Atom' xmlns:blogger='http://schemas.google.com/blogger/2018'> <id>tag:blogger.com,1999:blog-189623866</id> <title>TestBlog</title> <entry> <id>tag:blogger.com,1999:blog-189623866.post-4683409</id> <blogger:type>POST</blogger:type> <blogger:status>LIVE</blogger:status> <author> <name>Author</name> <blogger:type>BLOGGER</blogger:type> </author> <title>Test Post</title> <content type='html'>Lorem <p>Lorem ipsum dolor sit amet.</p>More Text....</content> I need to find/replace these entities with < and > so I get this in output.xml:
<?xml version='1.0' encoding='utf-8'?>.... <content type='html'>Lorem <p>Lorem ipsum dolor sit amet.</p>More Text....</content> Trying this
xmlstarlet edit -N ns="http://www.w3.org/2005/Atom" \ --update "//ns:content" --expr "replace(.,"<","<")" input.xml > output.xml throws the shell error zsh: command not found: lt
So I think I need to somehow to escape the < in the shell or in xmlstarlet.
is that possible?
"replace(.,"<","<")". Single quotes should fix that'replace(.,"<","<")'xmlXPathCompOpEval: function replace not found, Unregistered function. I'm using xmlstarlet --version shows 1.6.1, and these cryptic details: "compiled against libxml2 2.9.13, linked with 20913 compiled against libxslt 1.1.35, linked with 10135"xmlstarlet edit’s xpath arguments do not support XSLT functions.from martin7th.github.io/xmlstarlet-notes/#error-messages