2022 Developer Survey is open! Take survey.

Questions tagged [xmlstarlet]

Open source command line utility for XML file processing.

Filter by
Sorted by
Tagged with
2 votes
1 answer
44 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 ...
user avatar
  • 77
3 votes
1 answer
102 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 ...
user avatar
  • 77
-2 votes
1 answer
34 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="...
user avatar
  • 11
1 vote
2 answers
302 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 @...
user avatar
  • 1,145
0 votes
1 answer
63 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. ...
user avatar
  • 437
1 vote
0 answers
59 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-...
user avatar
  • 437
3 votes
2 answers
888 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 ...
user avatar
  • 31
1 vote
1 answer
184 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"> <...
user avatar
0 votes
1 answer
660 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 ...
user avatar
  • 103
0 votes
1 answer
66 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 ...
user avatar
  • 101
0 votes
3 answers
200 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 ...
user avatar
0 votes
1 answer
279 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 &...
user avatar
1 vote
2 answers
813 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 ...
user avatar
  • 13
1 vote
1 answer
91 views

How to extract specific node values without travesing via xmlstarlet

<xml> <email>asdadw@cutshort.io</email> <email>sadfasd@cutshort.io</email> <email>asdas@cutshort.io</email> <host> <ip>56....
user avatar
0 votes
1 answer
53 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> <...
user avatar
  • 1
1 vote
2 answers
388 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" ...
user avatar
1 vote
1 answer
96 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....
user avatar
  • 8,645
0 votes
1 answer
418 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-...
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&...
user avatar
4 votes
1 answer
3k 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> &...
user avatar
0 votes
1 answer
744 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 ...
user avatar
2 votes
1 answer
3k 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 *...
user avatar
1 vote
2 answers
2k 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....
user avatar
0 votes
1 answer
1k 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> &...
user avatar
-4 votes
2 answers
525 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 ...
user avatar
1 vote
1 answer
474 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/...
user avatar
  • 43
0 votes
4 answers
831 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 ...
user avatar
1 vote
1 answer
685 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 ...
user avatar
0 votes
2 answers
859 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" )...
user avatar
5 votes
1 answer
3k 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 ...
user avatar
2 votes
1 answer
940 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>...
user avatar
  • 89.1k
2 votes
1 answer
793 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></...
user avatar
  • 1,046
0 votes
1 answer
683 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 ...
user avatar
  • 2,039
8 votes
1 answer
820 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? ...
user avatar
  • 1,710
1 vote
2 answers
1k 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>...
user avatar
  • 11
5 votes
4 answers
689 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&...
user avatar
  • 499
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": <...
user avatar
  • 8,299