I'm trying to extract data from an xml file but without the codes. I've achieved it but i was wondering if there's a better way to do this.
sample data:
If you are using GNU awk, you can do all with one awk sweep.
Note that this assumes there is at most one value per line.
works for up to 3 per line.
To not print empty lines on lines with just one tag:
you could test whether $3 is empty:
Which will also ignore lines with empty value:
For any more sophisticated XML parsing, you'll probably want to use perl or some other tool that has xml modules.
awk doesn't know anything about xml.
The [<>] is a character group, it will split on either < or >. The [><] would do just the same.
With GNU awk you can use a regular expression for delimiter.
If it was [0-9], it would split on any digit.
With GNU awk you can use a regular expression for delimiter.
As far as I know, every major AWK implementation treats FS as a regular expression when it consists of more than one character (it's required by POSIX).
Hi,
I need help in extracting only the phone numbers between the continuous non empty xml tags in unix. I searched through a lot of forum but i did not get exact result for my query. Please help
Given below is the sample pipe delimited file. I have a lot of tags before and after... (6 Replies)
Hi All,
I have a requirement to change the data in xml file to required format.
Below is the scenario.
Please find the attached Xml file which contains data that I need to convert..
<ReleaseIndicatorList><ReleaseIndicator>Alternative... (0 Replies)
Hi unix Gurus,
I am really new to Unix Scripting. Please help me to create a shell script which reads the xml file and from that i need to fetch a particular information.
For example
<SOURCE BUSINESSNAME ="" DATABASETYPE ="Teradata" DBDNAME ="DWPROD3" DESCRIPTION ="" NAME... (2 Replies)
Hi,
I am new to shell scripting. I need to extract data between repeating tags from an xml file and store the data in an array to process it further.
<ns1:root xmlns:ns1="http://example.com/config">
<ns1:interface>in1</ns1:interface>
<ns1:operation attribute1="true" attribute2="abd"... (2 Replies)
Hi all,
I am trying to extract the values ( text between the xml tags) based on the Order Number.
here is the sample input
<?xml version="1.0" encoding="UTF-8"?>
<NJCustomer>
<Header>
<MessageIdentifier>Y504173382</MessageIdentifier>
... (13 Replies)
Is there a way to modify Non Null data between <host> and </host> tags to a new value ?- may be using sed/awk?
I tried this sed 's|.*<host>\(?*\)</host>.*|\<host>xxx</host>|' but it is updating the host which has null value - want opposite of this - Thanks in advance for you help!!
For... (2 Replies)
i have a file like
<fruits>
<apple>redcolor<\apple>
<bana:rolleyes:na>yellow color and it is<\banana>
</fruits>
i need a text between apple and bannana ans so on....
how to read a text between a tags it multiple tags with differnt names (9 Replies)
I am having xml document as below.
<transactionid>
00
</transactionid>
<tracknumber>
0
</tracknumber>
<key>
N/A
</key>
But the data contains leading and trailing spaces between the tags. Please let me know how can i remove these leading and trailing spaces between the tags.... (2 Replies)