Sponsored Content
Full Discussion: XML Phase with awk
Top Forums Shell Programming and Scripting XML Phase with awk Post 303027180 by pareshkp on Monday 10th of December 2018 12:41:43 PM
Old 12-10-2018
XML Phase with awk

Hi Guys,

Input XML File :-

Code:
  <managedObject class="RMOD_R" distName="MRBTS-101/X/R-7">
   <list name="activeCellsList">
    <p>15</p>
    <p>201</p>
   </list>
   <p name="aldManagementProtocol">True</p>
   <p name="serialNumber">845</p>
  </managedObject>

Output :-

Code:
CLI_RMOD_ACL^Mo,activeCellsList,activeCellsList,antennaPathDelayMeasurementCapable
CLI_RMOD_ACL^MRBTS-101/X/R-7,activeCellsList,15;201,True

Have tired below but not getting two value from same tag <p>

Code:
awk -F'[\\""\\>\\<]' -v OFS=',' 'BEGIN{print "Mo,activeCellsList,activeCellsList,antennaPathDelayMeasurementCapable"} /RMOD_R/{a=$5}/activeCellsList/{b=$3}/<p>/{c=$3}/antennaPathDelayMeasurementCapable/{print a,b,c,$5}' | sed 's/^/CLI_RMOD_ACL^/'

What I am getting from the above command

Code:
CLI_RMOD_ACL^Mo,activeCellsList,activeCellsList,antennaPathDelayMeasurementCapable
CLI_RMOD_ACL^MRBTS-101/X/R-7,activeCellsList,15,True


Last edited by vgersh99; 12-10-2018 at 01:44 PM.. Reason: fixed icode -> code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read content between xml tags with awk, grep, awk or what ever...

Hello, I trying to extract text that is surrounded by xml-tags. I tried this cat tst.xml | egrep "<SERVER>.*</SERVER>" |sed -e "s/<SERVER>\(.*\)<\/SERVER>/\1/"|tr "|" " " which works perfect, if the start-tag and the end-tag are in the same line, e.g.: <tag1>Hello Linux-Users</tag1> ... (5 Replies)
Discussion started by: Sebi0815
5 Replies

2. Solaris

init phase

Hello, Can somebody explain me the relationship between /sbin and /etc directories ? what is the relationship between them and what are the roles of files such as rcd.1 etc? (1 Reply)
Discussion started by: saudsos
1 Replies

3. Shell Programming and Scripting

How to add Xml tags to an existing xml using shell or awk?

Hi , I have a below xml: <ns:Body> <ns:result> <Date Month="June" Day="Monday:/> </ns:result> </ns:Body> i have a lookup abc.txtt text file with below details Month June July August Day Monday Tuesday Wednesday I need a output xml with below tags <ns:Body> <ns:result>... (2 Replies)
Discussion started by: Nevergivup
2 Replies

4. What is on Your Mind?

Prototyping New Responsive Mobile for UNIX.COM - Phase II

Have completed "Phase I" of our project "Prototyping New Responsive Mobile UNIX.COM", I am now moving to "Phase II" which will be changing many of the menus and buttons to use Javascript and CSS for the mobile site menus. For example, here is the new "main side menu" for the mobile site (below).... (63 Replies)
Discussion started by: Neo
63 Replies

5. War Stories

Postbit Changes (Phase II Upgrade)

Next in the pipeline, thinking I will work on postbit (the core of the posts) and try to get Bootstrap and badges working in postbit and not break the quick editors in the post. Note, I had to turn off the scrollbars in postbit for now because when I turn them on, it breaks the quick editor in... (11 Replies)
Discussion started by: Neo
11 Replies

6. What is on Your Mind?

Phase III: CSS Flexbox Upgrades

On my never ending quest to get rid of table tags and make the site responsive for all device sizes, I plan to use CSS Flexbox with jQuery. I tried using Bootstrap Flex and CSS Grids, but none of these worked as easy and clean as CSS Flexbox. For example, today I changed the top header area... (0 Replies)
Discussion started by: Neo
0 Replies

7. What is on Your Mind?

UserCP and Other Private User Area Revisions (Phase 0)

Hey, Having made a lot of progress on the "public facing" part of UNIX.COM, I may start working on remodeling the UserCP and other private areas. Today, I made some small changes; but nothing major in the UserCP area. However, I have not yet decided what to do with the UserCP: Keep... (0 Replies)
Discussion started by: Neo
0 Replies

8. What is on Your Mind?

Update to Advanced Search Page (Phase 1)

Update: I have completed the first phase of revamping the "Advanced Search" page using Bootstrap (desktop not mobile yet): https://www.unix.com/search.php https://www.unix.com/search.php I may change this to a Bootstrap modal later and change the CSS a bit more; but for now it is much... (0 Replies)
Discussion started by: Neo
0 Replies

9. Docker

Docker learning Phase-I

Hello All, I had recently learnt a bit of Docker(which provides containerization process). Here are some of my learning points from it. Let us start first with very basic question: What is Docker: Docker is a platform for sysadmins and developers to DEPLOY, DEVELOP and RUN applications ... (7 Replies)
Discussion started by: RavinderSingh13
7 Replies
XML::Handler::CanonXMLWriter(3) 			User Contributed Perl Documentation			   XML::Handler::CanonXMLWriter(3)

NAME
XML::Handler::CanonXMLWriter - output XML in canonical XML format SYNOPSIS
use XML::Handler::CanonXMLWriter; $writer = XML::Handler::CanonXMLWriter OPTIONS; $parser->parse(Handler => $writer); DESCRIPTION
"XML::Handler::CanonXMLWriter" is a PerlSAX handler that will return a string or write a stream of canonical XML for an XML instance and it's content. "XML::Handler::CanonXMLWriter" objects hold the options used for writing the XML objects. Options can be supplied when the the object is created, $writer = new XML::Handler::CanonXMLWriter PrintComments => 1; or modified at any time before calling the parser's `"parse()"' method: $writer->{PrintComments} = 0; OPTIONS
IOHandle IOHandle contains a handle for writing the canonical XML to. If an IOHandle is not provided, the canonical XML string will be returned from `"parse()"'. PrintComments By default comments are not written to the output. Setting comment to a true value will include comments in the output. AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us SEE ALSO
perl(1), PerlSAX James Clark's Canonical XML definition <http://www.jclark.com/xml/canonxml.html> perl v5.8.0 2000-02-22 XML::Handler::CanonXMLWriter(3)
All times are GMT -4. The time now is 08:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy