Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > XML parsing using PERL.... URGENT

Reply
Thread Tools

XML parsing using PERL.... URGENT

 
 
Ram
Guest
Posts: n/a
 
      04-13-2007
Hi,

I am new to PERL and i want to parse the xml file to csv with only 2
tags using perl.
Please help me out with this...


Sample of XML:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE FOF (View Source for full doctype...)>
- <FOF Name="BBH3" Previous="00001" Date="20070403">
- <OB cl="FOMessage.FIOMMessage.FIOMObject" no="1019.1008.51"
vr="1.43" od="1" mn="0">
<tx no="51" nm="provider1ID" mn="0" ky="1" />
<tx no="51" nm="provider2ID" mn="0" ky="1" />
<tx no="51" nm="provider3ID" mn="0" ky="1" />
<sp no="1008" nm="creationTime" mn="0" />
<tx no="1008" nm="author" mn="0" />
<nu no="1019" nm="revisionNo" mn="0" />
<sp no="1019" nm="createTimestamp" mn="0" />
<tx no="1019" nm="createUserID" mn="0" vl="WMS" />
<tx no="1019" nm="initiatorId" mn="0" />
<tx no="1019" nm="messageFromID" mn="0" />
<tx no="1019" nm="messageToID" mn="0" />
<fg no="1019" nm="isEndOfDelivery" mn="0" />
<fg no="1019" nm="isExecuted" mn="0" />
- <R no="1019" nm="fiomData">
- <RP mn="0">
- <OB cl="QuoteHolder.TopLevelObject.FIOMObject" no="208.1080.51"
vr="1.43" od="2" mn="0">
<tx no="51" nm="provider1ID" mn="0" ky="1" />
<tx no="51" nm="provider2ID" mn="0" ky="1" />
<tx no="51" nm="provider3ID" mn="0" ky="1" />
<cr no="208" nm="currency" mn="0" ky="1" vl="6 WKN 965642
Waehrung_BdB EO ISIN EU0009656420 BoersenkuerzelInland EUR
Waehrung_ISO4217 EUR DB_KEY 69" />
<R no="1080" nm="result" />
- <R no="1080" nm="vdpsInformation">
- <RP mn="0">
- <OB cl="VDPSInformation.FIOMObject" no="160.51" vr="1.43" od="3"
mn="0">
<tx no="51" nm="provider1ID" mn="0" ky="1" />
<tx no="51" nm="provider2ID" mn="0" ky="1" />
<tx no="51" nm="provider3ID" mn="0" ky="1" />
<fg no="160" nm="hasPendingActivities" mn="0" vl="FALSE" />
<tx no="160" nm="vstName" mn="0" vl="QuoteHolder" />
<tx no="160" nm="vstVersion" mn="0" vl="WM_003a" />
<em no="160" nm="foType" mn="0" dm="FOType" vl="500" />
<tx no="160" nm="createUserID" mn="0" vl="WMS" />
<sp no="160" nm="createTimestamp" mn="0" vl="05.07.2005 - 21:54:20
@0" />
<tx no="160" nm="updateUserID" mn="0" vl="WMS" />
<sp no="160" nm="updateTimestamp" mn="0" vl="03.04.2007 - 20:27:10
@0" />
<nu no="160" nm="vstQuality" mn="0" vl="10" />
<fg no="160" nm="isRelevant" mn="0" vl="TRUE" />
<tx no="160" nm="modificationReason" mn="0" />
<nu no="160" nm="revisionNo" mn="0" vl="939" />
<tx no="160" nm="remarks" mn="0" />
<fg no="160" nm="hasFutureMessages" mn="0" />
<nu no="160" nm="vstRequiredQuality" mn="0" vl="5" />
<tx no="160" nm="provider1Symbol" mn="0" ky="1" />
<tx no="160" nm="provider2Symbol" mn="0" ky="1" />
<tx no="160" nm="provider3Symbol" mn="0" ky="1" />
<em no="160" nm="dataStatusType" mn="0" dm="DataStatusType" />
<nu no="160" nm="vstMaximumQuality" mn="0" vl="10" />
<nu no="160" nm="newVstQuality" mn="0" />
<fg no="160" nm="isChecked" mn="0" />
<tx no="160" nm="messageInfo" mn="0" />
<fg no="160" nm="fotWizardIsDisabled" mn="0" />
<em no="160" nm="blockingCodeType" mn="0" dm="BlockingCodeType" />
<em no="160" nm="logicDeletionType" mn="0" dm="LogicDeletionType" /
>

<tx no="160" nm="foDBKey" mn="0" />
<fg no="160" nm="isOnDB" mn="0" vl="TRUE" />
<fg no="160" nm="isFastInsertion" mn="0" />
<em no="160" nm="priorityType" mn="0" dm="PriorityType" />
<R no="160" nm="genericInformations" />
<R no="160" nm="areaInformations" />
</OB>
</RP>
</R>
<R no="1080" nm="control" />
<R no="1080" nm="pendingActivity" />
<R no="1080" nm="pendingChange" />
- <WR no="208" tn="BTID3" nm="instrument">
<id no="0_BTID3" tn="BTID3" nm="destinationKey" mn="0" vl="5
CommonCode 16245151 WKN 628946 ISIN DE0006289465 BoersenkuerzelInland
EXHA DB_KEY 18615" />
</WR>
- <R no="208" nm="recentQuoteValues">
- <RP mn="0">
- <OB cl="QuoteValue.FIOMObject" no="213.51" vr="1.43" od="4" mn="0">
<tx no="51" nm="provider1ID" mn="0" ky="1" />
<tx no="51" nm="provider2ID" mn="0" ky="1"
vl="20070314K01005L21NULK02_1_4" />
<tx no="51" nm="provider3ID" mn="0" ky="1" />
<tx no="213" nm="quoteTypeIdSymbol" mn="0" vl="03_K02_1_4" />
<em no="213" nm="valueType" mn="0" dm="ValueType" vl="9001" />
<ft no="213" nm="quoteValue" mn="0" vl="130.97" />
<em no="213" nm="valueStyleType" mn="0" dm="ValueStyleType" vl="5" /
>

<ft no="213" nm="quoteSize" mn="0" />
<sp no="213" nm="quoteTime" mn="0" vl="14.03.2007 - 99:99:99 @99" /
>

<em no="213" nm="sizeStyleType" mn="0" dm="SizeStyleType" />
<em no="213" nm="reliabilityType" mn="0" dm="ReliabilityType" />
<fg no="213" nm="isCorrection" mn="0" />
<sp no="213" nm="validUntil" mn="0" />
<em no="213" nm="settlementTimeType" mn="0" dm="SettlementTimeType" /
>

<em no="213" nm="settlementCodeType" mn="0" dm="SettlementCodeType" /
>

<em no="213" nm="settlementStatusType" mn="0"
dm="QuoteSettleStatusType" />
<em no="213" nm="valueStyleRefinedType" mn="0"
dm="ValueStyleRefinedType" vl="9121" />
<tx no="213" nm="quoteTypeSchemeSymbol" mn="0" vl="03_Fondspreise" /
>

<em no="213" nm="fixingCapitalEventType" mn="0"
dm="FixingCapitalEventType" />
<lg no="213" nm="valueDescr" mn="0" />
<R no="213" nm="listingInformation" />
<R no="213" nm="providedService" />
<R no="213" nm="quoteListings" />
<RD no="213" nm="quoteType" mn="0" kyA="quoteTypeIdSymbol/
quoteTypeSchemeSymbol" />
</OB>
</RP>

My CSV file should be:
03042007
EU0009656420,130.97(quoteValue tag)


Please help me out with this...

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      04-14-2007
Ram <(E-Mail Removed)> wrote:

> Subject: XML parsing using PERL.... URGENT



Have you seen the Posting Guidelines that are posted here frequently?


> I am new to PERL



We can tell, because the name of the language is Perl, not PERL.


> Please help me out with this...



Sure. What part are you having trouble with?

> <tx no="213" nm="quoteTypeIdSymbol" mn="0" vl="03_K02_1_4" />
> <em no="213" nm="valueType" mn="0" dm="ValueType" vl="9001" />
> <ft no="213" nm="quoteValue" mn="0" vl="130.97" />



> My CSV file should be:
> 03042007
> EU0009656420,130.97(quoteValue tag)



You want a newline in the 1st CSV field?

There is no quoteValue tag anywhere in your data.

There is a tx tag and a em tag and a ft tag though,
there is also a ft tag with a quoteValue attribute value.

http://xml.silmaril.ie/authors/makeup/


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
Ram
Guest
Posts: n/a
 
      04-16-2007
On Apr 13, 8:58 pm, Tad McClellan <(E-Mail Removed)> wrote:
> Ram <(E-Mail Removed)> wrote:
> > Subject: XML parsing using PERL.... URGENT

>
> Have you seen the Posting Guidelines that are posted here frequently?
>
> > I am new to PERL

>
> We can tell, because the name of the language is Perl, not PERL.
>
> > Please help me out with this...

>
> Sure. What part are you having trouble with?
>
> > <tx no="213" nm="quoteTypeIdSymbol" mn="0" vl="03_K02_1_4" />
> > <em no="213" nm="valueType" mn="0" dm="ValueType" vl="9001" />
> > <ft no="213" nm="quoteValue" mn="0" vl="130.97" />
> > My CSV file should be:
> > 03042007
> > EU0009656420,130.97(quoteValue tag)

>
> You want a newline in the 1st CSV field?
>
> There is no quoteValue tag anywhere in your data.
>
> There is a tx tag and a em tag and a ft tag though,
> there is also a ft tag with a quoteValue attribute value.
>
> http://xml.silmaril.ie/authors/makeup/
>
> --
> Tad McClellan SGML consulting
> (E-Mail Removed) Perl programming
> Fort Worth, Texas


Thanks for the reply....

i have a complete xml file which isvery big and i m not able to attach
the complete file.. so i have taken a part of xml file and pasted
here
i have an xml file and i need to take only 3 values for each
object.... like ISIN, quoteValue and the date(header date)....
and below the quote value u can see quoteTime... the date in quoteTime
should be same as the header date....

there is a quote value tag here.... 4th line....
<tx no="51" nm="provider3ID" mn="0" ky="1" />
<tx no="213" nm="quoteTypeIdSymbol" mn="0" vl="03_K02_1_4" />
<em no="213" nm="valueType" mn="0" dm="ValueType" vl="9001" />
<ft no="213" nm="quoteValue" mn="0" vl="130.97" />
<em no="213" nm="valueStyleType" mn="0" dm="ValueStyleType"
vl="5" /
<em no="213" nm="valueStyleType" mn="0" dm="ValueStyleType" vl="5" /
<ft no="213" nm="quoteSize" mn="0" />
<sp no="213" nm="quoteTime" mn="0" vl="14.03.2007 - 99:99:99 @99" /

Yes, I need a new line




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What libraries should I use for MIME parsing, XML parsing, and MySQL ? John Levine Ruby 0 02-02-2012 11:15 PM
Basic XML Parsing question using System.XML Originlabs XML 0 04-23-2008 03:24 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Clarification on XML parsing & namespaces (xml.dom.minidom) Greg Wogan-Browne Python 1 01-28-2005 03:19 AM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM



Advertisments