639 questions
0
votes
2
answers
112
views
Use xmlstarlet and XPath to find/replace HTML entities in an XML node
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'?>
<...
1
vote
1
answer
68
views
Use xmlstarlet to remove node if it contains a certain node
I'm trying to remove all the comments from an XML export of a Blogger blog. This involves finding and deleting each <entry> that contains a child node of <blogger:type>COMMENT</blogger:...
0
votes
1
answer
102
views
Is it possible to edit the text or HTML contents of an XML node using xmlstarlet?
The answer to my earier question How do I access an XML node that uses quote marks with xmlstarlet? shows how to access a node using the namespace, and in that case, deleting the entire node.
...
1
vote
1
answer
53
views
How do I access an XML node that uses quote marks with xmlstarlet?
I'm trying to learn how to use xmlstarlet 1.6.1 https://xmlstar.sourceforge.net and I can't find how to escape the quotes or otherwise get xmlstarlet to recognize <content type="html"> ...
1
vote
1
answer
37
views
Querying the current namespace using xmlstarlet
System: Debian 12
xmlstarlet --version
1.6.1
compiled against libxml2 2.9.14, linked with 20914
compiled against libxslt 1.1.35, linked with 10135
below a reduced debugging (example.xml) version of ...
0
votes
2
answers
60
views
No output from xmlstarlet, yet XPATH exists inside web inspector
System Info
alinuxchap@libertus-desktop:~ $ uname -a
Linux libertus-desktop 6.12.25+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.25-1+rpt1 (2025-04-30) aarch64 GNU/Linux
alinuxchap@libertus-desktop:~ $ ...
0
votes
0
answers
73
views
xmlstarlet Sort XML based on value of element and return value of another element
I am trying to sort data using xmlstarlet.
Here is a sample of the XML I am querying.
<container>
<item>
<enabled>true</enabled>
<param name="label">...
2
votes
4
answers
115
views
xmlstarlet: Match / find by comments?
I have an XML file that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rrd SYSTEM "https://oss.oetiker.ch/rrdtool/rrdtool.dtd">
<!-- ...
0
votes
4
answers
170
views
Selecting multple values from an XML document in linux shell
XML: https://raw.githubusercontent.com/dp247/Freeview-EPG/master/epg.xml
Example
<tv>
<programme channel="VirginRadio.uk" start="20250319220000 +0000" stop="...
1
vote
2
answers
63
views
How do I change the separator from a space to a comma with xmlstarlet?
I am parsing a file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<detection-run>
<wireless-network>
<SSID>
<...
0
votes
6
answers
167
views
Duplicate a section of XML in bash (via xmlstartlet, xmllint, xq, xslt, ...)
I have a valid XML file.
I would like to duplicate a tag with contents via linux shell command(s).
By duplication I mean: copy <x>...</x> entirely, then paste right after the original.
I ...
0
votes
2
answers
89
views
xmlstarlet fails to indent when formatting HTML?
So, I have this as input file, temp.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
&...
1
vote
1
answer
85
views
External DTD not parsing / 'entity not defined error'
I'm not getting the external DTD, a local file in the same folder, to work with a relative or an absolute path. It is not expanding the variable and gives an error in both Firefox and xmlstarlet.
...
1
vote
2
answers
116
views
Creating valid XML with xmlstarlet
I want to use xmlstarlet to select some records of a gigantic .xml file. My problem is, that I need the output to be valid XML.
Minimal example:
using xmlstarlet sel -t -c "//record[@type='TypeA']...
0
votes
1
answer
50
views
Updating an existing xml file elements with attributes and values using xmlstarlet
I want to write a script to iterate over each element "NewTempP" with attributes and child element and copy the structure to element "fig" as child element. "NewTempP" ...
0
votes
1
answer
62
views
Updating an existing xml file elements using xmlstarlet
I have the following xml file:
<?xml version="1.0" encoding="UTF-8"?>
<sec>
<NewTempP>xxx</NewTempP>
<fig>
<label></label>
<...
0
votes
1
answer
199
views
xmlstarlet. Change multiple values in several lines to 1 line with values separated with "---". Is it possible?
I have this xml file ( truncated)
<adddata dn="articulo">
<attr name="code">
<value>34839473</value>
<value>12263522</value>
</attr>
</...
0
votes
1
answer
59
views
Can I query for a path through an XML document instead of just the leaf?
When I query an XML document with an XPATH, I only get the matched node(s) as a result. Is there a way to get the matched node(s) together with their parents up until root?
Lets take this very minimal ...
0
votes
1
answer
232
views
How to amend policy associated with Azure APIM APIs or operations with additional policy in automated way
I am trying to have an automated way to amend or apply additional policy on APIs or operations scope of Azure APIM and in my script i am able to read a variable $inbound or $outbound or $backend or $...
1
vote
2
answers
60
views
Return values based on dynamic expression in XmlStarlet
I want to get the text element based on the values given in "part1".
In below example XML, I want Text2 and Text5 to be returned, because the values in part1 refer to 2 and 5.
How can this ...
0
votes
1
answer
127
views
use xmlstarlet in shell script to read script variable value and insert in outpu xml file under specific section if the string is not present there
The parse yaml utility which I used in my shell script produces variables as below by eval command
policy1_name='ipfilter'
policy1_scope='api'
policy1_apiname='apiname'
policy1_inboundsession='rate-...
1
vote
1
answer
62
views
xmlstarlet for inserting string under xml fields
We have a policy.xml file as below and need to insert a string like below under each session of the xml file under (inbound or backend or outbound) just under <base /> depending on the ...
-1
votes
1
answer
794
views
Xmlstarlet executable file or any alternatives
Xmlstarlet is perfectly fits my needs, but faced issue, that it has no executable file (something like .jar file and etc).
I am trying to use it via a shell script, but server has no xmlstarlet ...
0
votes
2
answers
106
views
How can I use xmlstarlet and XPath to extract two elements at the same time
I have an xml document of the form
root
+- foo
+- bar
| +- @baz
I want to extract the value of /root/foo and of /root/bar/@baz in one go from the command line.
I can do
cat file.xml | xmlstarlet ...
0
votes
1
answer
118
views
Select first two words in a text using xmlstarlet
I have a simple xml file and I want to select 1) the first two occurrence words and 2) the rest in the element using xmlstarlet:
<fig>
<caption>Figure 1: Testing the figure</...
-1
votes
1
answer
249
views
How to extraxt HTML elements from inside the "content:encoded" part of an RSS feed?
I am trying to generate a newsletter which, among other stuff, includes news entries which are present on the website as well. The website is built with WordPress and has an RSS feed, which is not ...
3
votes
2
answers
139
views
XPath to select parent element if child element is missing
I have some XML like this: some.xml:
<one>
<two>
<three>
<four>some text</four>
</three>
</two>
<two>
<three>
<...
1
vote
1
answer
99
views
xmlstarlet is unable to add subnode when more than one xmlns attribute is present in the first element
I have an xml file test.gpx:
cat test.gpx
<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://...
0
votes
2
answers
73
views
xmlstarlet modify XML attribute in a body that also has an attribute with a specific value
I am creating a bash script to replace various values in a large XML file using XMLStarlet.
For one specific situation I fail to find the proper XMLStarlet commandline syntax.
I created a simplified ...
0
votes
1
answer
107
views
How to use XMLStarlet to lookup values in a second file
Let's assume we have two directories:
/home/a
/home/b
In directory a with have lots of XML files like this:
<root>
<id>87182378127381273</id>
<name>just a name</name>...
0
votes
1
answer
127
views
xmlstarlet insert fails without error message
I have an XML file that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ChannelList>
<channel>
<tvg-logo>https://tvpmlogopus.samsungcloud.tv/...
0
votes
2
answers
107
views
How to parse xpath from soap response to retrieve key value pair
Using bash I am trying to extract id and name as key value pair from below soap response and want to store this pair in csv file.
Below xmllint command is returning unwanted values as I am not able to ...
0
votes
1
answer
87
views
Use xmlstarlet to match on an attribute within a block and update a sibling attribute within the same block
Staring with an xml file, mg.xml
<?xml version="1.0"?>
<domain type="kvm">
<name>Comus</name>
<devices>
<interface type="network"&...
0
votes
2
answers
163
views
xmlstarlet add string "null" to self-closing tag
I am trying to create an sqlite3 loader from data returned from ( Service-Now's REST API ) but it uses self closing tags in it's xml return.
If I could convert the fields from empty self closing to an ...
0
votes
2
answers
922
views
How to split a single XML files into multiple XML files based on a given tag and renamed based that tag attribute?
I have several big archives in XML that I need to split the main node into files, and use the node's title attribute as name, eg:
<book title="ABC123" year="2000">
<...
0
votes
1
answer
737
views
convert xml to csv using xmlstarlet
I'm trying to convert an .xml to .csv using xmlstarlet. My filename is test.xml. The .xml data is like this:
<?xml version = '1.0' encoding = 'UTF-8'?>
<ws_export xmlns="http://ws_export....
4
votes
1
answer
3k
views
XMLStarlet Error: xmlSAX2Characters: huge text node: out of memory
I get an error while trying to parse an xml using xmlstarlet.
-:1.13408001: xmlSAX2Characters: huge text node: out of memory
...
1
vote
2
answers
128
views
How to swap the position of siblings in xml using xmlstarlet
I have the following xml file that I would like to swap the positions of the two siblings ("firstname" and "surname"):
From:
<?xml version="1.0" encoding="utf-8&...
-1
votes
1
answer
382
views
Problem when converting JSON to XML using jq and xmlstarlet
I am trying to convert JSON file into XML using following command which used JQ and XMSTARTLET
jq -r 'def walk(f): . as $in | if type == "object" then reduce keys_unsorted[] as $key (.; .[$...
-1
votes
1
answer
91
views
Edit android manifest file with xmlstarlet
I am trying to edit android manifest file with xmlstarlet. I want to change package attribute node.
Input file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:...
2
votes
1
answer
173
views
XMLstarlet filter and export
I need with xmlstarlet to filter the content of a XML and export elements based on subelement criteria
Using this kind of xml:
<products>
<product>
<product_code>1-70-032-0023</...
1
vote
1
answer
150
views
Does xpath explicitly allow undefined variables?
I was trying to pull some data out of an XML file using xmlstarlet, but
xmlstarlet sel -t -v '//div[contains(@class,'addresses')]/a'
was getting me a lot more than I expected.
I finally worked out - ...
0
votes
1
answer
333
views
Using xmlstarlet to pattern match element tags
I am trying to determine how to use xmlstarlet to get the xml tag and values when the tag elements aren't constant.
for example,
Input file:
<?xml version="1.0" encoding="us-ascii&...
1
vote
1
answer
115
views
Add attribute to XML
XML to edit -
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<broker xmlns="http://activemq.apache.org/schema">
<jaas-security domain=...
0
votes
0
answers
54
views
How to swap the positions of two siblings: using xmlstarlet
How do I swap the positions of two siblings:
From:
<article>
<name>
<firstname>John</firstname>
<surname>Pettterson</surname>
</name>
</...
3
votes
3
answers
430
views
Unescape xml file using xmlstarlet
I have two xml files A and B. I want to insert certain element nodes in A to B. It went fine but the imported elements were not "unescape" in B:
XML file A:
<?xml version="1.0"?&...
-2
votes
1
answer
310
views
Copying element nodes to another xml file using xmlstarlet
I want to copy from an xml file, two element nodes to another node (parent) in an existing xml file using xmlstarlet.
input example:
<?xml version="1.0" encoding="utf-8"?>
&...
-1
votes
1
answer
164
views
inserting missing node with attributes in xml file at a specific line only
Team,
I have below xml file which is missing a node at line 9. so I need to insert it and not anywhere else.
line to insert
<file branch-rate="0.0" complexity="0" path="src/...
-2
votes
1
answer
88
views
Add a new subnode as first sibling in xmlstarlet
I want to insert a subnode as the first subnode sibling using xmlstarlet. I have the following xml file:
src.xml
<xml>
<subnode> Peter Paul </subnode>
<subnode> Peter ...
-1
votes
2
answers
139
views
Search an Replace in a huge XML file
I have a large (750mb) XML file.
I would like to replace the string
file://localhost/E:/
with the following string
file:///Volumes/TOSHIBA%20EXT/
it appears throughout the xml file in a line like ...