Sponsored Content
Top Forums Shell Programming and Scripting how to get data from xml files tags(from data tags) Post 302221476 by danmero on Monday 4th of August 2008 01:54:27 PM
Old 08-04-2008
Code:
awk -F'[<|>]' '/<apple>/{f=1}/<banana>/{f=""}f{print $3}' file

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing leading and trailing spaces of data between the tags in xml.

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)
Discussion started by: jhmr7
2 Replies

2. Shell Programming and Scripting

How to update data between xml tags

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)
Discussion started by: harry_todd
2 Replies

3. Shell Programming and Scripting

Data between XML Tags

<?xml version="1.0" encoding="iso-8859-1" ?> <TABLE> <TEST> <ID> 123 </ID> <name> abc </name> </TEST> <TEST> <ID> 123 </ID> <name> abc2 </name> </TEST> </TABLE> <TABLE> <TEST> <ID> 456 </ID> <name> def </name> </TEST> <TEST> ... (8 Replies)
Discussion started by: eskay
8 Replies

4. Shell Programming and Scripting

print xml data without the tags.

Hi All, 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: $ cat xmlfile <code> <to>tove</to> <from>jani</from> <heading>reminder</heading> <body>dont forget me</body> </code> ... (4 Replies)
Discussion started by: Irishboy24
4 Replies

5. Shell Programming and Scripting

Shell script to extract data in repeating tags from xml

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)
Discussion started by: sailendra
2 Replies

6. Shell Programming and Scripting

Compare two xml files while ignoring some xml tags

I've got two different files and want to compare them. File 1 : <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record id="38,557"><columns><column><name>orge... (2 Replies)
Discussion started by: Shaishav Shah
2 Replies

7. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

8. UNIX for Advanced & Expert Users

Shell Script to read XML tags and the data within that tag

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)
Discussion started by: SmilePlease
2 Replies

9. Shell Programming and Scripting

How can I replace data in between xml tags to required format?

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)
Discussion started by: Prathyu
0 Replies

10. UNIX for Dummies Questions & Answers

Extracting data between continuous non empty xml tags

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)
Discussion started by: zen01234
6 Replies
XO(1)							    BSD General Commands Manual 						     XO(1)

NAME
xo -- emit formatted output based on format string and arguments SYNOPSIS
xo [-options] [argument...] DESCRIPTION
The xo utility allows command line access to the functionality of the libxo library. Using xo, shell scripts can emit XML, JSON, or HTML using the same commands that emit text output. --close <path> Close tags for the given path --depth <num> Set the depth for pretty printing --help Display this help text --html OR -H Generate HTML output --json OR -J Generate JSON output --leading-xpath <path> Add a prefix to generated XPaths (HTML) --open <path> Open tags for the given path --pretty OR -p Make 'pretty' output (add indent, newlines) --style <style> Generate given style (xml, json, text, html) --text OR -T Generate text output (the default style) --version Display version information --warn OR -W Display warnings in text on stderr --warn-xml Display warnings in xml on stdout --wrap <path> Wrap output in a set of containers --xml OR -X Generate XML output --xpath Add XPath data to HTML output The xo utility accepts a format string suitable for xo_emit(3) and a set of zero or more arguments used to supply data for that string. xo "The {k:name} weighs {:weight/%d} pounds.0 fish 6 TEXT: The fish weighs 6 pounds. XML: <name>fish</name> <weight>6</weight> JSON: "name": "fish", "weight": 6 HTML: <div class="line"> <div class="text">The </div> <div class="data" data-tag="name">fish</div> <div class="text"> weighs </div> <div class="data" data-tag="weight">6</div> <div class="text"> pounds.</div> </div> The --wrap <path> option can be used to wrap emitted content in a specific hierarchy. The path is a set of hierarchical names separated by the '/' character. xo --wrap top/a/b/c '{:tag}' value XML: <top> <a> <b> <c> <tag>value</tag> </c> </b> </a> </top> JSON: "top": { "a": { "b": { "c": { "tag": "value" } } } } The --open <path> and --close <path> can be used to emit hierarchical information without the matching close and open tag. This allows a shell script to emit open tags, data, and then close tags. The --depth option may be used to set the depth for indentation. The --leading-xpath may be used to prepend data to the XPath values used for HTML output style. #!/bin/sh xo --open top/data xo --depth 2 '{tag}' value xo --close top/data XML: <top> <data> <tag>value</tag> </data> </top> JSON: "top": { "data": { "tag": "value" } } EXAMPLE
% xo 'The {:product} is {:status}0 stereo "in route" The stereo is in route % xo -p -X 'The {:product} is {:status}0 stereo "in route" <product>stereo</product> <status>in route</status> ADDITIONAL DOCUMENTATION
Complete documentation can be found on github: http://juniper.github.io/libxo/libxo-manual.html libxo lives on github as: https://github.com/Juniper/libxo The latest release of libxo is available at: https://github.com/Juniper/libxo/releases SEE ALSO
libxo(3), xo_emit(3) HISTORY
The libxo library was added in FreeBSD 11.0. AUTHOR
Phil Shafer BSD
December 4, 2014 BSD
All times are GMT -4. The time now is 05:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy