Questions tagged [xmlstarlet]

Open source command line utility for XML file processing.

Filter by
Sorted by
Tagged with
3 votes
1 answer
685 views

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. <netbooks> <file id="2"> <...
Daniel's user avatar
  • 343
3 votes
1 answer
224 views

'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<<EOF > /tmp/file.xml <root> &...
Mévatlavé Kraspek's user avatar
4 votes
1 answer
191 views

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: <event type='cue' units='sec'> <onset>11.134</onset> ...
XMLnewbie's user avatar
3 votes
2 answers
767 views

Remove all namespace attributes from xml using xmlstarlet

I want to remove all the namespace attributes from the following XML. <md:EntityDescriptor xmlns="urn:_" xmlns:md="_"></md:EntityDescriptor> I have tried to remove ...
s1n7ax's user avatar
  • 396
1 vote
1 answer
107 views

How to download latest MediaWiki from command line?

One can download MediaWiki via a web browser GUI here: https://www.mediawiki.org/wiki/Download The download link there isn't version agnostic (it changes any time a new version comes out), that makes ...
automation's user avatar
5 votes
2 answers
412 views

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 ...
cas's user avatar
  • 77.7k
5 votes
2 answers
1k views

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 <text> tags. If I use native XML ...
Googlebot's user avatar
  • 1,919
2 votes
1 answer
106 views

How to untag, in an XML file, a chain of tagged characters that are embedded within specified tags

What is the xmlstarlet command to untag, in an XML file, a chain of tagged characters that are embedded within specified tags? Example: searching every occurrence of the tag <b>, that needs to ...
Matt5's user avatar
  • 87
4 votes
1 answer
662 views

How to rename, in an XML file, specific tags that are embedded in some other specific tags

What is the xmlstarlet command to replace a tag value by another one, only for specified tags embedded in other specified tags? Example: searching every occurance of the tag b, that needs to be ...
Matt5's user avatar
  • 87
-1 votes
1 answer
44 views

Change the version number from 97 to 98 in an XML file [closed]

I want to change the version number with respect to the ip. For example for this ip 10.228.134.226, it should change the version number from 97 to 98 <qa:browsers> <browser name="...
raghav's user avatar
  • 11
2 votes
2 answers
4k views

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

Example:- <item href="cover.jpeg" id="cover" media-type="image/jpeg"/> I'd like to select @id="cover" and media-type="image/*" and retrieve @...
Jeremy Boden's user avatar
  • 1,300
0 votes
1 answer
341 views

xmlstarlet command for batch processing .xhtml files

I've tried xmlstarlet for processing an individual .xhtml files. xmlstarlet fo --omit-decl --recover --html file.xhtml This command process an individual files and prints output on terminal only. ...
minto's user avatar
  • 511
1 vote
0 answers
207 views

XMLstarlet to fix image tags and replace path for images

I have multiple .XHTML files in the folder. The top declaration part is as follows: <?xml version="1.0" encoding="UTF-8"?> <html xml:lang="en-us" lang="en-...
minto's user avatar
  • 511
3 votes
2 answers
2k views

reading XML file and extract only node names and structure

I need to audit XML file structures and need to generate a report that shows only the DOM tree structure and omit the values. Essentially, I just the node names only and no values. I tried using ...
Kinnara's user avatar
  • 31
1 vote
1 answer
814 views

Update XML parameter, with namespace, using xmlstarlet

I have this XML file: <?xml version="1.0" encoding="UTF-8" ?> <engineConfiguration xmlns="http://bla.com/engine/management/engineConfiguration"> <...
Dave Macias's user avatar
0 votes
1 answer
2k views

Convert this regex to be friendly within sed

I am trying to perform this regex with sed, but seems like sed does not support? It says invalid character range echo "$info" | sed -e 's/(?:\d[\s-.]*){12,19}/*/g' Trying to match any ...
Bao Thai's user avatar
  • 103
0 votes
1 answer
384 views

xmlstarlet how to select tag immediately before selected tag

I scan scribus SLA files and wish to find the text having some specific paragraph styles. SLA file format is a quite flat XML format and there are several paragraphs in a row, each being separated ...
JLuc's user avatar
  • 111
0 votes
3 answers
626 views

Trying to read XML attributes from multiple files and replacing them with a number 1.25 times greater than they were before

I am trying to write a bash script or something similar, that I can use to modify all occurrences in a bunch of xml files with one click. I have 24 xml files, each containing a few dozen lines and ...
xOverload86x's user avatar
0 votes
1 answer
819 views

xmlstarlet select iteratively multiple occurences of same tag

I am trying to select attribute values within multiple occurrences of same tag using xmlstarlet within a for loop ,but the $i in the iteration is not taking value as expected , I am referencing it as &...
sriram2207's user avatar
3 votes
2 answers
2k views

Use xmlstarlet to remove an entire element that matches an attribute value?

My question is similar to sed - Delete XML node containing certain element - Unix & Linux Stack Exchange. Trying to implement the suggestions there has kept me busy all day, but I haven't managed ...
J-S's user avatar
  • 33
1 vote
1 answer
847 views

How to extract specific node values without travesing via xmlstarlet

<xml> <email>[email protected]</email> <email>[email protected]</email> <email>[email protected]</email> <host> <ip>56....
Abhinav Gupta's user avatar
0 votes
1 answer
159 views

How to Search XML Block and Delete the same

This is my XML. <configGroup> <type>SERVER_CONFIG</type> <configProperty id="Server48"> <configProperty> <name>Server Name</name> <...
cotton's user avatar
  • 1
1 vote
2 answers
707 views

I want to add a namespace prefix to the tags of the default name space of an XML document from the shell

I have a SVG file, which is an XML document: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" ...
Pierre François's user avatar
1 vote
1 answer
185 views

parse Duration from xml using xmlstarlet

The file looks like <MediaInfo xmlns="https://mediaarea.net/mediainfo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://mediaarea.net/mediainfo https://mediaarea....
Siva's user avatar
  • 9,067
0 votes
1 answer
997 views

insert a line into xml using xmlstarlet

I have an XML file which looks like so: <?xml version="1.0" encoding="UTF-8"?> <!-- Solr managed schema - automatically generated - DO NOT EDIT --> <schema name="default-...
JohnJ's user avatar
  • 135
0 votes
1 answer
2k views

how to parse the xml that have multiple properties and names

if we are having a XML script like this , How to get the value of a particular name using XML parsing <?XML> <conf> <prop><name>something</name><value>1</value&...
Bhargav's user avatar
4 votes
1 answer
4k views

Creating new elements with xmlstarlet

I have been trying to to add new elements to an XML file. Original file: <levela> <levelb> </levelb> </levela> I'm trying to get the following result: <levela> &...
code_ninja's user avatar
0 votes
1 answer
1k views

Extract select match value of same contents in XML file

I using this command for below xml file. xmlstarlet sel -t -v '//channel[protected = "True"]/playlist_url' -nl file.xml and result; host.net/aa/vodpr host.net/aa/vodpr/con_tv_r.php Can I choose a ...
Ali Haydar Doğan's user avatar
2 votes
1 answer
4k views

How to extract selected value in XML

I would like to extract only a value from similar content XML file. Example; <?xml version="1.0" encoding="UTF-8" ?> <items> <channel> <title><![CDATA[*** text 1 text *...
Ali Haydar Doğan's user avatar
1 vote
2 answers
3k views

Change XML node's value, using sed?

I have the following node in an XML document: <client-version>1.2.8</client-version> How can I replace replace the node's value, 1.2.8, with 1.2.9? Wanted output: <client-version>1....
Cathal Mac Donnacha's user avatar
0 votes
1 answer
2k views

Set bash variables from XML tags

I have the following xml file <root> <deviceID>IO238470374109730497</devicdeID> <KeyValuePairs> <KeyValuePair> <BASE-URL>site.com</BASE-URL> &...
Mustafa W Alani's user avatar
-4 votes
2 answers
654 views

Extract content between tags which is having sub tag

Extract the desired content from the file using "xmlstarlet" or "sed" or "awk" or some similar tool. The process should refer the full name of the particular businessprocesses and then should just ...
manoj k's user avatar
1 vote
1 answer
690 views

Parsing 12,000+ XML files

I have a folder that contains 12,000+ XML files. I need to get a list of files within that folder that meet certain criteria. In the XML file there is a node called /BillingData/InvoiceLinesList/...
snert's user avatar
  • 43
0 votes
4 answers
1k views

need to join only certain lines of a xml file together [duplicate]

I would like to transform this XML to where only certain lines are joined together. This is so I can later grep only specific lines. If this XML used attributes, then the data would already be in 1 ...
Jaymer Jaymer.'s user avatar
1 vote
1 answer
820 views

XmlStarlet xml to csv output as 'NaNNaNNaN'

I wrote a a query xmlstarlet sel -T -t -m badges/row -v "concat(@row, ',')" -n Badges.xml and the output is repeated as: NaNNaNNaN... for what is likely the amount of rows in the Badges.xml file. I ...
Greg Iven's user avatar
0 votes
2 answers
1k views

Executing Command in Pipes

I need to understand why I am not able to execute the following. ls -d /data/VT60000* | xargs -IDIRECTORY find DIRECTORY -type f -iname RJ\*.xml | xargs -IFILE sh -c ' XML=$( xmlstarlet fo -D "FILE" )...
Noel Alex Makumuli's user avatar
5 votes
1 answer
4k views

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 ...
Shahar Hamuzim Rajuan's user avatar
2 votes
1 answer
1k views

Rename XML elements to a sequence

I was looking at a possible XML-based solution to another question. I'm aware of its accepted answer, which offers sed and python solutions. The given XML fragment is: <Names> <Name>...
Chris Davies's user avatar
2 votes
1 answer
1k views

How exactly does xmlstarlet move work

I want to move around elements in an xml document with xmlstarlet Specifically I want to make the following changes <parent> <before/> <span><a>blah</a></...
Att Righ's user avatar
  • 1,176
0 votes
1 answer
841 views

Insert a tag with a unique identifier into a XML

I'm able to add a new node with a custom fixed value to my XML file in this way, with xmlstarlet: xmlstarlet ed --subnode "/legge190/data/lotto" --type elem -n newsubnode \ -v "myvalue" But how to ...
aborruso's user avatar
  • 2,785
8 votes
1 answer
991 views

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? ...
Thufir's user avatar
  • 1,840
1 vote
2 answers
2k views

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

The sample XML looks like this: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <root> <level01> <field01>AAAAAAAAAAAAAAAAAAAA</field01> <field02>...
sdfsdf's user avatar
  • 11
5 votes
4 answers
814 views

Can I convert fields in XML to tags using xmlstarlet?

I want to convert fields in Tags to tags within that tag for example <book name="Data Structure" price="250" pages="350"/> to <book name="Data Structure&...
krishna's user avatar
  • 519
1 vote
1 answer
2k views

Why isn't this XMLStarlet Query Working?

I'm trying to write a simple bash script that parses price info from the ebay developer API search results. Here's an example of XML search results for "Detective Comics 700": <...
Mike B's user avatar
  • 8,839