arunshankar.c has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I have an XML File as below:
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:<?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>
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#!/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"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML parsing
by choroba (Cardinal) on Nov 05, 2012 at 13:27 UTC | |
by arunshankar.c (Initiate) on Nov 05, 2012 at 14:10 UTC | |
Re: XML parsing
by rjt (Curate) on Nov 05, 2012 at 13:50 UTC | |
by arunshankar.c (Initiate) on Nov 05, 2012 at 14:11 UTC | |
Re: XML parsing
by sundialsvc4 (Abbot) on Nov 05, 2012 at 15:15 UTC |
Back to
Seekers of Perl Wisdom