Hi All, I have an XML File as below:
<?xml version="1.0" encoding="UTF-8"?> <ServiceChangeRequest Operation="Activate" SubscriberKey="|IMSI_NUMBER +|" AlternateSubscriberKey="|MSISDN_NUMBER|" Refresh="false"> <RequiredServices> <ServiceDescription ServiceTag="|service|"> <ParameterDesc ParameterTag="MSISDN" Parameter +Value="|MSISDN_NUMBER|"/> <ParameterDesc ParameterTag="SCPId" ParameterV +alue="|SCPID|"/> <ParameterDesc ParameterTag="ServiceClass" Par +ameterValue="|service_class|"/> <ParameterDesc ParameterTag="PromotionPlan" Pa +rameterValue="|promo_plan|"/> </ServiceDescription> <ServiceDescription ServiceTag="VMSS"> <ParameterDesc ParameterTag="VMSMSISDN" Parame +terValue="|VMSMSISDN_NUM|"/> </ServiceDescription> <ServiceDescription ServiceTag="VCFD"/ +> <ServiceDescription ServiceTag="CALW"/ +> <ServiceDescription ServiceTag="AUC"> <ParameterDesc ParameterTag="KI" ParameterValu +e="|KI|"/> </ServiceDescription> <ServiceDescription ServiceTag="CONTENT"/> <ServiceDescription ServiceTag="GPRS"/> <ServiceDescription ServiceTag="CAMEL"/> <ServiceDescription ServiceTag="APNWAP"/> <ServiceDescription ServiceTag="APNMMS"/> </RequiredServices> </ServiceChangeRequest>
In the above XML file, I have pipe '|' delimited entered eg. : |MSISDN_NUMBER| I want to split the file according to pipe delimited format. Below is the code that I have written:
#!/usr/bin/perl open(FILE, 'removed.xml') or die "Can't read file 'filename' [$!]\n"; + while (<FILE>) { $document .= $_ } print "document is $document\n"; @lines = split("\|",$document); for ($i=0;$i< @lines;$i++) { print "$_\n"; }
I have read from an XML file called removed.xml into variable $document. Now the problem is the @lines does not show any output. Can you please suggest a way in which the XML file can be splitted according to '|' pipe delimited format. Sorry: My mistake, I got the output, please apologize,my question is itself wrong Thanks Arun

In reply to XML parsing by arunshankar.c

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.