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
Template::XML(3pm)					User Contributed Perl Documentation					Template::XML(3pm)

NAME
Template::XML - XML plugins for the Template Toolkit SYNOPSIS
[% USE XML; dom = XML.dom('foo.xml'); xpath = XML.xpath('bar.xml'); simple = XML.simple('baz.xml'); rss = XML.simple('news.rdf'); %] DESCRIPTION
The Template-XML distribution provides a number of Template Toolkit plugin modules for working with XML. The Template::Plugin::XML module is a front-end to the various other XML plugin modules. Through this you can access XML files and direc- tories of XML files via the Template::Plugin::XML::File and Template::Plugin::XML::Directory modules (which subclass from the Tem- plate::Plugin::File and Template::Plugin::Directory modules respectively). You can then create a Document Object Model (DOM) from an XML file (Template::Plugin::XML::DOM), examine it using XPath queries (Template::Plugin::XML::XPath), turn it into a Perl data structure (Tem- plate::Plugin::XML::Simple) or parse it as an RSS (RDF Site Summary) file. The basic XML plugins were distributed as part of the Template Toolkit until version 2.15 released in May 2006. At this time they were extracted into this separate Template-XML distribution and an alpha version of this Template::Plugin::XML front-end module was added. AUTHORS
Andy Wardley wrote the Template Toolkit plugin modules, with assistance from Simon Matthews in the case of the XML::DOM plugin. Matt Sergeant wrote the XML::XPath module. Enno Derksen and Clark Cooper wrote the XML::DOM module. Jonathan Eisenzopf wrote the XML::RSS mod- ule. Grant McLean wrote the XML::Simple module. Clark Cooper and Larry Wall wrote the XML::Parser module. James Clark wrote the expat library. COPYRIGHT
Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template, Template::Plugins, Template::Plugin::XML, Template::Plugin::XML::DOM, Template::Plugin::XML::RSS, Template::Plugin::XML::Simple, Template::Plugin::XML::XPath perl v5.8.8 2008-03-01 Template::XML(3pm)
All times are GMT -4. The time now is 07:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy