473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

XML to text file

Hi all,

I am new to perl and xml ...
Can anyone help me out to read an xml file and write it to text file.
Apr 17 '07 #1
6 2694
KevinADC
4,059 Expert 2GB
What have you tried so far?
Apr 17 '07 #2
What have you tried so far?
i haven't started coding yet....as i am new to perl and xml, looking out for the way to proceed... help me
Apr 17 '07 #3
KevinADC
4,059 Expert 2GB
Beginning Perl
Apr 17 '07 #4
Hi,

I am new to perl and xml.... please help me out with the following as this is urgent:
Can anyone help me with the code....
I have a xml file:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE FOF (View Source for full doctype...)>
- <FOF Name="BBH3" Date="20070413" Last="1">
- <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" vl="iss-blade4.local.wmgruppe.de_21221_2_0" />
<tx no="1019" nm="messageToID" mn="0" vl="iss-blade4.local.wmgruppe.de_21221_2_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="3">
<tx no="51" nm="provider1ID" mn="0" ky="1" />
<tx no="51" nm="provider2ID" mn="1" ky="1" vl="WMS" ov="" />
<tx no="51" nm="provider3ID" mn="0" ky="1" />
<cr no="208" nm="currency" mn="4" 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="3">
<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="4" 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="4" dm="FOType" vl="500" />
<tx no="160" nm="createUserID" mn="0" vl="WMS" />
<sp no="160" nm="createTimestamp" mn="0" vl="05.07.2005 - 22:02:15 @0" />
<tx no="160" nm="updateUserID" mn="3" vl="WMS" ov="unknown" />
<sp no="160" nm="updateTimestamp" mn="3" vl="16.04.2007 - 10:24:40 @0" ov="15.04.2007 - 11:26:04 @0" />
<nu no="160" nm="vstQuality" mn="4" vl="10" />
<fg no="160" nm="isRelevant" mn="4" vl="TRUE" />
<tx no="160" nm="modificationReason" mn="0" />
<nu no="160" nm="revisionNo" mn="3" vl="529" ov="528" />
<tx no="160" nm="remarks" mn="0" />
<fg no="160" nm="hasFutureMessages" mn="0" />
<nu no="160" nm="vstRequiredQuality" mn="4" 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="1" vl="10" ov="" />
<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="4" 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="3" vl="1 WKN 977961" ov="5 CommonCode 8492301 WKN 977961 ISIN DE0009779611 BoersenkuerzelInland FPJB DB_KEY 18022" />
</WR>
- <R no="208" nm="recentQuoteValues">
- <RP mn="0">
- <OB cl="QuoteValue.FIOMObject" no="213.51" vr="1.43" od="4" mn="1">
<tx no="51" nm="provider1ID" mn="0" ky="1" />
<tx no="51" nm="provider2ID" mn="1" ky="1" vl="20070413K01005L21NULK02_1_4" ov="20070413K01005L21NULK02_1_4" />
<tx no="51" nm="provider3ID" mn="0" ky="1" />
<tx no="213" nm="quoteTypeIdSymbol" mn="1" vl="03_K02_1_4" ov="03_K02_1_4" />
<em no="213" nm="valueType" mn="1" dm="ValueType" vl="9001" ov="9001" />
<ft no="213" nm="quoteValue" mn="1" vl="75.35" ov="75.35" />
<em no="213" nm="valueStyleType" mn="1" dm="ValueStyleType" vl="5" ov="5" />
<ft no="213" nm="quoteSize" mn="0" />
<sp no="213" nm="quoteTime" mn="1" vl="13.04.2007 - 99:99:99 @99" ov="13.04.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="1" dm="ValueStyleRefinedType" vl="9121" ov="9121" />
<tx no="213" nm="quoteTypeSchemeSymbol" mn="1" vl="03_Fondspreise" ov="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>
- <RP mn="0">
- <OB cl="QuoteValue.FIOMObject" no="213.51" vr="1.43" od="5" mn="1">
<tx no="51" nm="provider1ID" mn="0" ky="1" />
<tx no="51" nm="provider2ID" mn="1" ky="1" vl="20070413K02004L21NULK02_1_4" ov="20070413K02004L21NULK02_1_4" />
<tx no="51" nm="provider3ID" mn="0" ky="1" />
<tx no="213" nm="quoteTypeIdSymbol" mn="1" vl="03_K02_1_4" ov="03_K02_1_4" />
<em no="213" nm="valueType" mn="1" dm="ValueType" vl="9002" ov="9002" />
<ft no="213" nm="quoteValue" mn="1" vl="71.76" ov="71.76" />
<em no="213" nm="valueStyleType" mn="1" dm="ValueStyleType" vl="4" ov="4" />
<ft no="213" nm="quoteSize" mn="0" />
<sp no="213" nm="quoteTime" mn="1" vl="13.04.2007 - 99:99:99 @99" ov="13.04.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="1" dm="ValueStyleRefinedType" vl="9121" ov="9121" />
<tx no="213" nm="quoteTypeSchemeSymbol" mn="1" vl="03_Fondspreise" ov="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>
- <R no="208" nm="providedService">
- <RP mn="0">
- <OB cl="ProvidedService.FIOMObject" no="310.51" vr="1.43" od="11" mn="4">
<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" />
<dt no="310" nm="beginDate" mn="0" />
<dt no="310" nm="endDate" mn="0" />
- <WR no="310" tn="BTID2" nm="institution">
<id no="0_BTID2" tn="BTID2" nm="destinationKey" mn="3" vl="1 Institution 848758" ov="5 Abwicklungsstelle 4039 Betreuer 4039 Institution 848758 IBEI DE08487588 DB_KEY 54487" />
</WR>
- <WR no="310" tn="BTID5" nm="instrumentService">
<id no="0_BTID5" tn="BTID5" nm="destinationKey" mn="4" vl="1 InvestmentFondsPreise WMGruppe" />
</WR>
</OB>
</RP>
</R>
</OB>
</RP>
</R>
</OB>

Output:
I need a perl script and the output (txt file) of the perl script is as follows:
#(ISIN, valueType, quoteValue,quoteTime)
DE0009779611,9001,75.35,20070413
DE0009779612,9001,97.12,20070413
.
.


Need to take the Date from the header ie 3rd line and compare it with the date in quoteTime. If the date matches, write it into txt file.If it doesn't match, then discard
Here i need to get only the quoteValue for valueType =9001 and not for 9002

Would appreciate if anyone helps me with this
Apr 17 '07 #5
KevinADC
4,059 Expert 2GB
the scenario is:

you start the code, we help.

Or we point you to resouces that can get you started. I did that in your other post but you seem to have ignored that.
Apr 18 '07 #6
savanm
85
First u must show ur code...then only v wl know ur need

use Cwd;
$path = getcwd();
$path =~s/\\/\//sgi;
opendir(DIR,$path) || die("cannot open the file");
@html = grep(/\.xml/,readdir(DIR));
closedir(DIR);
foreach $files (@xml)
{

submain($path."\/".$files);
}

sub submain()
{
$xml = shift;
$txt = $html;
$txt=~s/\.xml/\.txt/g;
open(FIL,$xml);
then proceed According to ur need...........
This may help u.
Apr 18 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Ling Lee | last post by:
Hi all. I'm trying to write a program that: 1) Ask me what file I want to count number of lines in, and then counts the lines and writes the answear out. 2) I made the first part like this: ...
1
by: Rigga | last post by:
Hi, I am new to Python and need to parse a text file and cut parts out i.e. say the text file contained 5 rows of text: line 1 of the text file line 2 of the text file line 3 of the text...
27
by: Eric | last post by:
Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there...
16
by: thenightfly | last post by:
Ok, I know all about how binary numbers translate into text characters. My question is what exactly IS a text character? Is it a bitmap?
7
by: Chris | last post by:
Hi I can use a text file as a datasource but am unable to get the datatable to see the text file as having multiple columns. Everything gets put into the first column in the datatable. Sample of...
3
by: bbepristis | last post by:
Hey all I have this code that reads from one text file writes to another unless im on a certian line then it writes the new data however it only seems to do about 40 lines then quits and I cant...
1
by: Osoccer | last post by:
...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem: I need a...
10
by: bluemountain | last post by:
Hi there, Iam new to python forms and programming too I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2,...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.