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

44 questions
8
votes
1 answer

how to massage or format html in order to parse with xmstarlet?

Do I first need to run html in the wild through something like jsoup? Not to make it valid in a human sense, might turn it to gibberish, but at least so that xmlstarlet can process the file? Preferably looking for a CLI which can be installed and…
Thufir
  • 1,810
  • 6
  • 33
  • 60
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
  • 1
  • 7
  • 119
  • 185
5
votes
2 answers

Deleting an XML tag in a huge file

I have difficulty parsing a huge XML file (about 100GB with large nodes). I am trying to reduce the node sizes by deleting unnecessary tags. For example, any tags. If I use native XML parsers such as xmlstarlet xmlstarlet ed -P -d '//text'…
Googlebot
  • 1,909
  • 3
  • 25
  • 40
5
votes
1 answer

Edit XML using xmlstarlet only in one subnode

When using the command: -bash-4.2$ xmlstarlet ed -u "/configurations/rules/rule/branch" -v 'DAVID' config.xml > final.xml I see that the output file was changed to DAVID, But it was changed globally every place the tag "branch" was declared. But I…
5
votes
4 answers

Can I convert fields in XML to tags using xmlstarlet?

I want to convert fields in Tags to tags within that tag for example to 250 350 I want to perform this operation in Linux…
krishna
  • 519
  • 1
  • 6
  • 8
4
votes
1 answer

Sum values in xmlstarlet from two siblings?

I am using xmlstarlet to extract text from elements with a specific preceding sibling event. An example from the XML file: 11.134 0.2 CUER
XMLnewbie
  • 43
  • 2
4
votes
1 answer

Creating new elements with xmlstarlet

I have been trying to to add new elements to an XML file. Original file: I'm trying to get the following result: value1
code_ninja
  • 49
  • 1
  • 2
3
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
  • 341
  • 11
3
votes
1 answer

'xmlstarlet edit' using a variable as XPath

When you follow the doc: xmlstarlet edit --help you can read that --var can be used to declare a XPath expression as a variable. Generating moc file: cat< /tmp/file.xml x y