Questions tagged [xml]

A simple, very flexible text format that stands for eXtensible Markup Language.

Filter by
Sorted by
Tagged with
0 votes
1 answer
37 views

extract block from XML with different ending tags (<tag>...</tag> vs <tag ... />)

Given an XML with some blocks ending within the same tag and others with a separate tag: <parent name="parent_1" team="team_a"> <child name="child_1" team=&...
  • 13
3 votes
1 answer
89 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> &...
4 votes
1 answer
86 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> ...
1 vote
0 answers
71 views

Cannot Edit KVM Machine's XML; Failed to validate against schema

When trying to save XML changes in Vim this error occurs: error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng Extra element ...
1 vote
1 answer
200 views

How can I sort XML elements by their attributes?

How can I sort this XML? first by alphabetical element: module before property. then by the alphabetical name attribute: <module name="ClassTypeParameterName"/> before <module name=...
  • 135
1 vote
2 answers
36 views

XMLERR: Element '=").*?(?=")</regex' not closed while using lookaround

I am trying to use lookaround element in PCRE2 regex for Wazuh tool, i need to match strings which are in double quotes and made the below regex however it looks its picking up "<" ...
  • 1,791
0 votes
2 answers
49 views

script to swap strings containing newlines within text file (XML)

I am using Arch which was updated a couple of weeks ago. Packages is use are Arch 6.0.10-arch2-1 BASH 5.1.16(1)-release gnu sed 4.9 gnu grep 3.8 openbox 3.6.1 Within my Openbox rc.xml text file I ...
  • 677
1 vote
2 answers
130 views

Extract IP:PORT from a curl output

I want to get list ip:port from the curl output of curl https://www.gametracker.com/search/?sort=5&order=ASC I cannot post the whole output as it is very big, just posting the part from where we ...
  • 378
3 votes
3 answers
274 views

Create CSV from an xml file

I'm trying to create a csv from an xml with just some information from the xml. This is my xml : <?xml version="1.0" encoding="UTF-8"?> <hashlist version = "2.0" ...
  • 31
0 votes
1 answer
61 views

Using sed to search multiple strings in XML file

I need to filter a big file XML and find the string using a multiple conditions. I need a filter a email if cnisfCF equal true and natg_passwordAlreadyResetedPostMigration is true. Anyone can help ? &...
-1 votes
3 answers
67 views

Extracting SMS data from a XML

I have a large xml file of my SMS messages. I want to put them into an easily accessible csv format. I've been trying to extract the 'address', 'messageBody' and 'messageTime' sections specifically ...
  • 1
0 votes
1 answer
247 views

Getting specific entries of a log file using awk

I'm currently trying to use awk to grab items from massive log files matching specific criteria. Essentially, I need to be able to pull the entire command, marked by a transaction ID, based on ...
1 vote
2 answers
812 views

How may I replace a string in an XML file?

I am trying to replace the string inside an XML file. From <hello="value" exampleno="xxxx:yyyyyyyy/dd=eeeee-ffffff,aa=bb ccc,dd=eeee,ff=gggg,hh=iii,jj=kkk,ll=mmmm" /> I want ...
  • 19
3 votes
3 answers
365 views

Identify strings between patterns and print entire region between pattern if string is found. Perferably using awk

There are similar questions but none of them quite address the issue I have. Simply put, I need to print every block that contains any string I'm looking for. Each block start line contains: <entry ...
  • 877
-4 votes
3 answers
109 views

Unix command to grep above and below until a certain text appears

Consider the below example where '12345' is a unique id for the entire xml. <Tag 1> a b c d 12345 x y z </Tag 1> I need a command where I can grep '12345' in my file and go above and ...
0 votes
3 answers
91 views

find text between > < for a given variable and change text to something else

If I search file eg. file.xml for s_webdomain I will get: <hostname oa_var="s_webhost">hostname</hostname> <externURL oa_var="s_external_url">https://...
2 votes
1 answer
238 views

Insert contents of file into XML attribute

I have a text file called branch.txt: $ cat branch.txt DEMAND_NAME-CR-1234 DEMAND_NAME-CR-8970 Using the above branch name, I have to find and replace some values using a sed command: branch_name=`(...
  • 23
0 votes
2 answers
112 views

search of .xml files without certain tag through mac os terminal

I would appreciate having your advice on the below. Having a folder name "ABC" with thousands of .xml files inside. The core structure of XMLs is the same: <product abcd…> <...
0 votes
3 answers
83 views

How to get all numbers AND IPs from string using regex?

Let's say I have the following example string: <ETH0_IP><![CDATA[10.0.100.10]]></ETH0_IP> I would like to extract the first number and the IP in the following format: 0 10.0.100.10 ...
  • 402
0 votes
3 answers
36 views

I need a bash script that replaces every number between two arrows in a file with a 0

the name of the file is types.xml and lists hundreds of different items. this is what it looks like: <type name="CanisterGasoline"> <nominal>50</nominal> ...
0 votes
1 answer
24 views

How to display only the content between opening and closing tags in XML file?

How to search the XML file using grep or similar for a particular tag but show only the content between opening and closing tags? Here is the exact tag I'd like to locate: <max-diskusage>...
  • 189
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 ...
  • 1,869
2 votes
1 answer
86 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 ...
  • 77
3 votes
1 answer
469 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 ...
  • 77
2 votes
1 answer
2k views

How to replace, in an XML file, specific strings of characters in some specified tags with other strings of characters embedded in tags

I need to replace, in an XML file, specific strings of characters in some specified tags with other strings of characters embedded in tags. Example searching every occurance of an example, that needs ...
  • 77
-1 votes
1 answer
140 views

How to parse the xml start tag to end tag using shellscript?

I have XML file like below, called sample.xml: <m:properties> <d:>ABCD</d:> <d:>1234</d:> <d:>0048</d:> <d:>0.0</d:> </m:properties> <m:...
  • 1
-1 votes
2 answers
444 views

Change the value of an XML tag using awk or sed

So I have an XML file <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/...
-2 votes
2 answers
155 views

I need to update a tag <abc><\abc> with variables from another file. Output should be an xml file with all those values comma separated within abc tag

I need help updating an xml file, file1.xml which has a tag name <abc> <\abc>. The file2.txt has numbers fixed length numbers (1 number in each row): 1234 5678 1435 I need output to a ...
  • 11
0 votes
1 answer
157 views

Insert line after an XML file

I have a file that contains a small XML snippet. I also have a large XML file. The large XML file has a line that includes <build>. In Bash, How can I insert the contents of the small file after ...
-1 votes
1 answer
37 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="...
  • 11
0 votes
5 answers
904 views

Replace hyphen(s) with underscore(s) within angle brackets in a file

I’m aware of how to replace string; e.g., replace hyphen with underscore in a file. However, I wish to replace all hyphens with underscore for all text that falls within angle brackets in a given file....
  • 427
3 votes
4 answers
858 views

Extracting sea level pressure from KML using Shell

I'm currently working on a little project; in a kml file called weatherdata.kml, I would like to extract the sea level pressure for each <Placemark> element. I'm trying to parse the information ...
user avatar
0 votes
1 answer
662 views

replacing value in xml file using sed value from variable missing ""s

hi can some one please help me here i am trying to replace value in tomcat server.xml file username using sed command <Resource username="user1" password="xxxxxxxx"/> below ...
  • 3
-1 votes
2 answers
107 views

Counting TAB/SPACES before a particular line

I have a requirement in which I need to identify a field in a file, If found than I will have to add a new line and add some text. But I want to count the number of SPACES before the word found so ...
4 votes
3 answers
908 views

Using sed to replace one character with another within an xml tag

I need to replace the character S with T in: <episode-num system="onscreen">S1 E12</episode-num> The result I expect: <episode-num system="onscreen">T1 E12</...
  • 43
0 votes
0 answers
68 views

xsltproc not supporting path cmdline argument?

I am using xsltrpoc for XSLT 1.0 stylesheets in linux box. I am using XSLT against my XML files. I need to import one file say base.xsl to my file say main.xsl. I realized to use the xsltproc --path ...
0 votes
3 answers
442 views

Change the format of a XML string which have date timestamp in the middle inside a lot of text files in the same folder (*.txt)

I have a lot of text files with dates in XML formated as follows: <DATA2020-04-13T08:59:05.427 /> Need to change into this: <DATA>2020-04-13T08:59:05.427</DATA> Notes: The date and ...
0 votes
1 answer
130 views

ABRT complains about failure of /usr/sbin/setroubleshootd

On a CentOS 7 machine, I get: ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1641301975 [root@my_machine ~]# abrt-cli list --since 1641301975 id ...
  • 8,123
0 votes
2 answers
84 views

Sed an XML balise

Please, I have this xml balise inside my test.xml file <ingressAnnotations>nginx.ingress.kubernetes.io/server-snippet: | location @custom_503 { return 503 &quot;&lt;html&gt; &...
  • 677
0 votes
4 answers
208 views

Problems with replacing XML tag contents using sed

I have the following XML piece: <value id="1" creatorId="0" creationTime="1639487132" expirationTime="1639573532">+380554446363</value> <value id=...
0 votes
2 answers
300 views

extract all XML tags and values

I have this long line: <hdr><name><first>John</first><mid></mid><last>Smith</last></name><dob>04181995</dob><phone>5550001111<...
  • 1
2 votes
2 answers
726 views

Find a pattern (of a child tag) and replace the entire parent tag at XML files, without using sed tool [duplicate]

Is there a way to find a pattern (of a child tag) and replace the entire parent tag, using regular expressions?  I'm working from a Linux server without a graphics environment. I have XML like: <?...
0 votes
1 answer
1k views

Retrieving value of XML tags

I have an xml file like below: <FileHeader>SampleFile</FileHeader> <Name>aaaa</Name> <Place>bufnkf</Place> <Name> bjfbhj</Name> <Place>bvdhbf</...
0 votes
4 answers
562 views

How to remove text between two keywords in a textfile

Context : GNU/Linux Ubuntu. I've a file made of thousands of lines and I'd like to have a script that will remove some lines between 2 specific keywords. Initial file is like: bla bla ... bla bla ...
0 votes
1 answer
221 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. ...
  • 467
0 votes
2 answers
122 views

How to extract few tabs from a xml file using zgrep or sed

I have a big size file like 5GB with .gz. Inside that file, we have few XML files that contains values that I want to search and extract just in case if those values are there. For example I want to ...
1 vote
0 answers
153 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-...
  • 467
0 votes
4 answers
3k views

How to extract a portion of an XML tag value in a Bash script

I have a XML file like this (A.xml) : <?xml version="1.0"?> <RunParameters xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
  • 509
2 votes
1 answer
290 views

How to add closing XML tags with sed

I have the following example in the XML doc: <meta name=Originator content="text/html; charset=iso-8859-6"> <meta name=ProgId content=Word.Document> <meta name=Generator ...
  • 221
1 vote
1 answer
294 views

How to keep double quotes in a bash execution inside sed

I have a log file containning a lot of line like this: 2021/09/03-13:11:05;QUEUE.INBOUND;4;ID:myhost.mydomain.net-7756-1629822315072-199:973:1:1:1;MISC;"<?xml version="1.0" encoding=&...
  • 1,667

1
2 3 4 5
9