Sponsored Content
Top Forums Shell Programming and Scripting can i do XML parsing usind sed Post 302117016 by anbu23 on Thursday 10th of May 2007 02:44:04 AM
Old 05-10-2007
Can you show the sample input and output required?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Parsing xml file using Sed

Hi All, I have this(.xml) file as: <!-- define your instance here --> <instance name='ins_C2Londondev' user='' group='' fullname='B2%20-%20London%20(dev)' > <property> </property> </instance> I want output as: <!-- define your instance here --> <instance... (3 Replies)
Discussion started by: kapilkinha
3 Replies

2. Shell Programming and Scripting

parsing xml with awk/sed

Hi people!, I need extract from the file (test-file.txt) the values between <context> and </context> tag's , the total are 7 lines,but i can only get 5 or 2 lines!!:confused: Please look my code: #awk '/context/{flag=1} /\/context/{flag=0} !/context/{ if (flag==1) p rint $0; }'... (3 Replies)
Discussion started by: ricgamch
3 Replies

3. Shell Programming and Scripting

XML Parsing

Hi, Need a script to parse the following xml file content <tag1 Name="val1"> <abc Name="key"/> <abc Name="pass">*********</abc> </tag1> <tag2 Name="Core"> <Host Name="a.b.c"> <tag1 Name="abc"> <abc Name="ac">None</abc> ... (4 Replies)
Discussion started by: Mavericc
4 Replies

4. Shell Programming and Scripting

printing portion of the output usind sed/awk

friends, i am a newbie in scripting. could someone help me in selecting only the last column of below ps command output ? mqm 14 16466 0 Sep 15 ? 0:01 /opt/mqm/bin/runmqlsr -r -m QMGR.INBOUNDSSL -t TCP -p 1415 -i 5.1.26.5 mqm 12 16700 0 Sep 15 ? 0:00... (4 Replies)
Discussion started by: unahb1
4 Replies

5. Shell Programming and Scripting

Help in parsing xml file (sed/nawk)

I have a large xml file as shown below: <input> <blah> <blah> <atr="blah blah value = ""> <blah> <blah> </input> ..2nd chunk... ..3rd chunk... ...4th chunk... All lines between <input> and </input> is one 'order' and this 'order' is repeated... (14 Replies)
Discussion started by: shekhar2010us
14 Replies

6. Shell Programming and Scripting

Parsing XML

Learned People, Hello ! Till today, for the most part, all of the tricky questions/situations that I encountered were already posted by other folks and all I had to do was peruse through these one at a time and I could find some sort of an answer and all I had to do was add some minor tweaks... (5 Replies)
Discussion started by: ManoharMa
5 Replies

7. UNIX for Advanced & Expert Users

XML Parsing

I had a big XML and from which I have to make a layout as below *TOTAL+CB | *CB+FX | CS |*IR | *TOTAL | -------------------------------------------------------------------------------------------------- |CB FX | | | | DMFXNY EMSGFX... (6 Replies)
Discussion started by: manas_ranjan
6 Replies

8. Shell Programming and Scripting

Parsing XML

I am trying to parse an xml file and trying to grab certain values and inserting them into database table. I have the following xml that I am parsing: <dd:service name="locator" link="false"> <dd:activation mode="manual" /> <dd:run mode="direct_persistent" proxified="false" managed="true"... (7 Replies)
Discussion started by: $criptKid617
7 Replies

9. Shell Programming and Scripting

XML: parsing of the Google contacts XML file

I am trying to parse the XML Google contact file using tools like xmllint and I even dived into the XSL Style Sheets using xsltproc but I get nowhere. I can not supply any sample file as it contains private data but you can download your own contacts using this script: #!/bin/sh # imports... (9 Replies)
Discussion started by: ripat
9 Replies

10. Shell Programming and Scripting

XML parsing

I have an xml file where the format looks like below <SESSIONCOMPONENT REFOBJECTNAME ="pre_session_command" REUSABLE ="NO" TYPE ="Pre-session command"> <TASK DESCRIPTION ="" NAME ="pre_session_command" REUSABLE ="NO" TYPE ="Command" VERSIONNUMBER ="1"> ... (8 Replies)
Discussion started by: r_t_1601
8 Replies
Data::Stag::BaseGenerator(3pm)				User Contributed Perl Documentation			    Data::Stag::BaseGenerator(3pm)

NAME
Data::Stag::BaseGenerator - base class for parsers and other event generators SYNOPSIS
# writing the parser package MyParser; use base qw(Data::Stag::BaseGenerator); sub parse_fh { my ($self, $fh) = shift; my $lnum = 0; $self->start_event('data'); while (<$fh>) { ++$lnum; $self->line_no($lnum); # do stuff $self->start_event('foo'); # ... $self->event(blah=>5); # if (/incorrect_line/) { $self->parse_err('line not in correct format'); } # ... $self->end_event('foo'); } $self->pop_stack_to_depth(0); } 1; # using the parser my $p = MyParser->new; my $h = MyHandler->new; # see Data::Stag::BaseHandler my $eh = Data::Stag->makehandler; $p->handler($h); $p->errhandler($eh); $p->parse($file); # result tree print $h->stag->xml; # write parse errs on standard err printf *STDERR $p->errhandler->stag->xml; # using the parser from the command line unix> stag-parse.pl -p MyParser -w xml -e err.xml > out.xml # using the parser from the command line via intermediate handler unix> stag-handle.pl -p MyParser -m MyHandler -w xml -e err.xml > out.xml DESCRIPTION
This is the base class for all parsers and event generators parsers/generators take some input (usually a filehandle, but a generator could be a socket listener, for example) and fire stag events stag events are start_event NODENAME evbody DATA end_event NODENAME {optional} event NODENAME DATA These events can be nested/hierarchical If uncaught, these events are stacked into a stag tree, which can be written as xml or one of the other stag formats specialised handlers can be written to catch the events your parser throws For example, you may wish to write a pod parser that generates nested events like this: <pod> <section> <type>head1</type> <name>NAME</name> <text>Data::Stag - Structured Tags datastructures</text> </section> ... </pod> (see the source for Data::Stag::PodParser for details) You can write handlers that take the pod-xml and generate something - for example HTML parsers may encounter unexpected things along the way - they may throw an exception, and fall over - or they may choose to fire an error event. by default, error event streams are diverted to STDERR. You can create your own error handlers PUBLIC METHODS
new Title: new Args: Return: L<Data::Stag::BaseGenerator> Example: CONSTRUCTOR handler Title: handler Function: GET/SET ACCESSOR METHOD Args: handler L<Data::Stag::BaseHandler> optional Return: L<Data::Stag::BaseHandler> Example: $p->handler(MyHandler->new); each parser has a handler - all events generated are passed onto the handler; the default handler simply sits there collecting events errhandler Title: errhandler Function: GET/SET ACCESSOR METHOD Args: handler L<Data::Stag::BaseHandler> optional Return: L<Data::Stag::BaseHandler> Example: $p->errhandler(Data::Stag->makehandler); each parser has an error handler - if the parser encounters things it does not expect, it can pass errors to the errorhandler if no errorhandler is set, an XML event handler that writes to STDERR is used cache_errors Title: cache_errors Args: Return: Example: $p->cache_errors If this is called, all errors will be cached rather than written to STDERR The error list can be accessed like this $p->parse($fn); @errs = $p->errhandler->stag->get_error; parse Example - $parser->parse($file1, $file2); Returns - Args - filenames str-LIST parses a file parse Example - $parser->parse_fh($fh) Returns - Args - fh FILEHANDLE parses an open filehandle PROTECTED METHODS
These methods are only of interest if you are making your own parser/generator class start_event NODENAME evbody DATA end_event NODENAME {optional} event NODENAME DATA SEE ALSO
Data::Stag Data::Stag::BaseHandler perl v5.10.0 2008-06-03 Data::Stag::BaseGenerator(3pm)
All times are GMT -4. The time now is 08:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy