Questions tagged [xmlstarlet]

Open source command line utility for XML file processing.

XMLStarlet is a set of command line tools which can be used to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way to what is done for plain text files using grep, sed, awk, diff, patch, join, etc commands.

Documentation: on Wikipedia

45 questions
5
votes
2 answers

how to delete a div with a specific class from XHTML using xstarlet?

I have several hundred .xhtml files in a sub-directory(*) and I want to delete all DIVs with a specific class (and the entire contents of those DIVs - including other divs, spans, image and paragraph elements) from them. The DIV may appear zero,…
cas
  • 78,579
4
votes
1 answer

Extract value of element in XML with xmlstarlet

My situation is very specific, and I am a beginner with xmlstarlet. I have an XML file like the one below, which contains hundreds of entries. 2008-06-04 16:40 Daniel
Daniel
  • 363
3
votes
2 answers

Remove all namespace attributes from xml using xmlstarlet

I want to remove all the namespace attributes from the following XML. I have tried to remove xmlns using following command which does not change the input in anyway. xmlstarlet…
s1n7ax
  • 418
2
votes
2 answers

How can I use xmlstarlet to query a tag for two attribute values?

Example:- I'd like to select @id="cover" and media-type="image/*" and retrieve @href. My current "solution" seems to be:- xmlstarlet sel -t -m "//_:item[@id='$opf_cover_name']" -v @href -o…
Jeremy Boden
  • 1,320
1
vote
2 answers

How to convert multi level xml to a single line containing all levels using XMLSTARLET

The sample XML looks like this: AAAAAAAAAAAAAAAAAAAA BBBBBBBB CCCCCCCCCCCCCCCCCCCC
sdfsdf
  • 11
0
votes
1 answer

XMLStarlet with using a variable in XPath expression

I have this command: find . -iname '*.xml' | xargs xmlstarlet sel -N z="http://abc.com/article/1.0/" \\ --var zgtag="SuperTag" -t -m "/z:profile-extension" -i "//z:tag='$zgtag'" \\ -n -f -o "," -v "count(//z:zgContextsAnonymTotal[z:tag='$zgtag'])"…
basZero
  • 153