Sponsored Content
Top Forums Shell Programming and Scripting Help in parsing XML output file in perl. Post 302745281 by rkrish on Monday 17th of December 2012 04:51:33 AM
Old 12-17-2012
Question Help in parsing XML output file in perl.

Hi I have an XML output like :
Code:
  <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <envelope>
- <body>
- <outputGetUsageSummary>
- <usgSumm rerateDone="5">
- <usageAccum accumId="269" accumCaptn="VD_DP_AR" inclUnits="9999999.00" inclUnitsUsed="0.00" shared="false" pooled="false" prorated="false" realtimeSbscrpShared="false" inclUnitsRolledOver="0.00" maxRolloverUnits="0.00" inclUnitsToBeRolledOver="0.00" rolloverAvailableFlag="false" prevCycleReleasedFlag="false" sbscrpUsedUnits="0.00">
  <prices svcPriceSeqNbr="00000RH2LS808H7" svcName="VD_DP_AR" captnText="Vm Deposit Free Airtime" inclUnits="9999999.00" inclUnitsUsed="0.00" ntwrkUnitsIncl="599999940.00" ntwrkUnitsUsed="0.00" maxAvailNtwrkUnits="599999940.00" displayUnitsIncl="9999999.20" displayUnitsUsed="0.00" maxAvailDisplayUnits="9999999.20" ntwrkUnitId="1" displayUnitId="3" /> 
  </usageAccum>
- <usageAccum accumId="270" accumCaptn="VD_IN_AR" inclUnits="9999999.00" inclUnitsUsed="0.00" shared="false" pooled="false" prorated="false" realtimeSbscrpShared="false" inclUnitsRolledOver="0.00" maxRolloverUnits="0.00" inclUnitsToBeRolledOver="0.00" rolloverAvailableFlag="false" prevCycleReleasedFlag="false" sbscrpUsedUnits="0.00">
  <prices svcPriceSeqNbr="00000RH2LT888H8" svcName="VD_IN_AR" captnText="Vm Deposit Free Airtime" inclUnits="9999999.00" inclUnitsUsed="0.00" ntwrkUnitsIncl="599999940.00" ntwrkUnitsUsed="0.00" maxAvailNtwrkUnits="599999940.00" displayUnitsIncl="9999999.20" displayUnitsUsed="0.00" maxAvailDisplayUnits="9999999.20" ntwrkUnitId="1" displayUnitId="3" /> 
  </usageAccum>
  </usgSumm>
  </outputGetUsageSummary>
  </body>
  </envelope>

The XML output will be stored in a file called $output:
system("$resub_path -stdin < $input_xml_file >$output");


I need to grep the values of the fields 'inclUnits' ,'inclUnitsUsed','shared' (in Bold)for each accumId i.e., for '269','270' from the output file.
I have these values stored in an array ('269','270').
Can anyone help me in grepping the above mentioned corresponding filelds for each accumid from the $output file and store them in variables?

Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HTTP Query Request & Parsing returned XML output

I have a PERL script from which I need to make a HTTP request to Web Servlet (Essentially a URL with variables and values like &Variable1=AAAAAA&Variable2=BBBBBBBBB&Variable3=CCCCCCC). The Web servlet returns an XML result which needs to be parsed for the contents of the result within the program.... (15 Replies)
Discussion started by: jerardfjay
15 Replies

2. UNIX for Advanced & Expert Users

xml parsing error in perl

******************PERL VERSION************************ This is perl, v5.8.1 built for i386-linux-thread-multi ERROR!!!!---Undefined subroutine &main::start called at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/XML/Parser/Expat.pm line 469. *********************PERL... (1 Reply)
Discussion started by: bishweshwar
1 Replies

3. UNIX for Dummies Questions & Answers

Help parsing a XML file ....

Well I have read several threads on the subject ... but being a newbie like me makes it hard to understand ... What I need is the following: Input data: ------- snip --------- <FavouriteLocations> <FavouriteLocations class="FavouriteList"><Item... (6 Replies)
Discussion started by: misak
6 Replies

4. Shell Programming and Scripting

Random XML Parsing - using Perl

Given the XML: <?xml version="1.0" encoding="UTF-8"?> <reference> <refbody> <section> <p> <ul> <li><xref href="file1.dita#anchor" /></li> <li><xref href="file2.dita#anchor" /></li> </ul> </p> </section> <section> <p> <xref href="file3.dita#anchor" /> </p> <p> <xref... (4 Replies)
Discussion started by: ricksj
4 Replies

5. Shell Programming and Scripting

Bash XML Parsing using Perl XPath

I have a bash script that needs to read input from an XML file, which includes varying numbers of a certain type of child node. I want to be able to iterate through all the child nodes of a given parent. I installed the Perl XML-XPath package from search.cpan.org. Once it's installed, from bash,... (4 Replies)
Discussion started by: jfmorales
4 Replies

6. Shell Programming and Scripting

parsing xml file

Hello! We need to parse weblogic config.xml file and display rows in format: machine:listen-port:name:application_name In our enviroment the output should be (one line for every instance): Crm-Test-Web:8001:PIA:peoplesoft Crm-Test-Web:8011:PIA:peoplesoft... (9 Replies)
Discussion started by: annar
9 Replies

7. Shell Programming and Scripting

parsing XML result by using perl?

for some reasons, i need to parse the XML result by using perl. for instance, this is a sample XML result: <Response> <status>success</status> <answer>AAA::AAA</answer> <answer>BBB::BBB</answer> </Response> then i can use this way : my @output = (); foreach my $parts (@all) ##@all... (2 Replies)
Discussion started by: tiger2000
2 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Parsing XML file

I want to parse xml file sample file....... <name locale="en">my_name<>/name><lastChanged>somedate</lastChanged><some more code here> <name locale="en">tablename1<>/name><lastChanged>somedate</lastChanged> <definition><dbquery><sources><sql type="cognos">select * from... (10 Replies)
Discussion started by: ms2001
10 Replies

10. Shell Programming and Scripting

Help with parsing xml file

Hi, Need help with parsing xml data in unix and place it in a csv file. My xml file looks like this: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <iwgroups> <nextid value="128"> </nextid> <iwgroup name="RXapproval" id="124" display-name="RXapproval"... (11 Replies)
Discussion started by: ajayakunuri
11 Replies
XML(3pm)						User Contributed Perl Documentation						  XML(3pm)

NAME
CGI::XML - Perl extension for converting CGI.pm variables to/from XML SYNOPSIS
use CGI::XML; $q = new CGI::XML; # convert CGI.pm variables to XML $xml = $q->toXML; $xml = $q->toXML($root); # convert XML to CGI.pm variables $q->toCGI($xml); DESCRIPTION
The CGI::XML module converts CGI.pm variables to XML and vice versa. CGI::XML is a subclass of CGI.pm, so it reads the CGI variables just as CGI.pm would. METHODS
$q = new CGI::XML creates a new instance of CGI::XML. You also have access to all of the methods in CGI.pm. $q->toXML([$root]) where $root is an optional parameter that specifies the root element. By default, toXML will not return a root element. $q->toCGI($xml) where $xml is the XML you would like to convert to CGI.pm parameters. Values in the XML will overwrite any existing values if they exist. NOTE
CGI::XML does not currently handle multiple selections passed from HTML forms. This will be added in a future release. AUTHOR
Jonathan Eisenzopf <eisen@pobox.com> CONTRIBUTORS
David Black <dblack@candle.superlink.net> SEE ALSO
perl(1), XML::Parser(3). perl v5.8.8 2004-12-05 XML(3pm)
All times are GMT -4. The time now is 03:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy