sub get4Gdata { my( $doc, $filename, $tarrecordNumber, $filesubdirIndex, $pmlinehead +er) = @_; #I need the below XML in a format #plmnId=26290,HenBId=768012,crnti=132,srbId=1 #VS.numberOfDlSrbSduReceived 53 #VS.numberOfDlSrbPduTransmitted 53 #plmnId=26290,HenBId=768012,crnti=132,srbId=2 #VS.numberOfDlSrbSduReceived 30 #VS.numberOfDlSrbPduTransmitted 30 # # #<mi> # <mt>VS.numberOfDlSrbSduReceived</mt> # <mt>VS.numberOfDlSrbPduTransmitted</mt> # <mv> # <moid>plmnId=26290,HenBId=768012,crnti=132,srbId=1</moid> # <r>53</r> # <r>53</r> # </mv> # <mv> # <moid>plmnId=26290,HenBId=768012,crnti=132,srbId=2</moid> # <r>30</r> # <r>30</r> # </mv> #</mi> my @milist = $doc->getElementsByTagName('mi'); foreach my $mi (@milist) { my $miname = $mi; my @moidlist = $mi->getElementsByTagName('moid'); foreach my $moid (@moidlist) { my $moidname = $moid->firstChild()->nodeValue(); $moidname =~ s/ //g; $moidname =~ s/\n//g; $moidname =~ s/\r//g; print " ", $moid->getName(), " ", $moid->nodePath(), " ", $moidna +me, "\n"; my @mtlist = $mi->getElementsByTagName('mt'); foreach my $mt (@mtlist) { my $mtname = $mt->firstChild()->nodeValue(); #my $mtvname = $mi->getElementsByTagName('r'); $mtname =~ s/ //g; $mtname =~ s/\n//g; $mtname =~ s/\r//g; print " ", $mt->getName(), " ", $mt->nodePath(), " ", $mtn +ame, "\n"; #my @mtvvalue = $mi->getElementsByTagName('r'); #foreach my $r (@mtvvalue) { #my $mtvname = $mi->getElementsByTagName('r'); #my $mtvname = $r->firstChild()->nodeValue(); #print " ", $r->getName(), " ", $r->nodePath(), " ", $mtvn +ame, "\n"; #print $mtvname, "\n"; # print " ", $rlistname->getName(), " ", $rlistname->nodePa +th(), " ", $rlistname, , "\n"; #===================================================================== +======================= } } } } }

In reply to Re: Need to convert the XML into file by aryapintu
in thread Need to convert the XML into file by aryapintu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.