[thelist] Help using Perl to parse XML?

Luther, Ron ron.luther at hp.com
Fri Oct 17 17:11:35 CDT 2003


Hi Gang,

Had a 'hot potato' dropped in my lap ... I'm going to receive a large 
number of XML files (of variable size).  I need to pull three fields 
out of each file and outbound those (comma separated) into a single 
file that I can do some analysis on ... by Wednesday. ;-O

I'm not a 'perl-monger' but I think I can whip something together that 
will go through all of the files in a directory and rip two of the 
fields I want:

One sits between <BELNR> and </BELNR> tags - so I should be able to 
find and grab it.  Another one sits between <ZZHPOT> and </ZZHPOT> 
tags - so I should be able to find and grab that one as well.

The third one is a little more troublesome ...

I'm not an XML-head, but it looks like the third value I'm interested 
in sits *between* <ORGID> and </ORGID> tags *within* a 
<E1EDK14 SEGMENT="1"> tag *if* that <E1EDK14 SEGMENT="1"> bugger also 
happens to have a value of "012" sitting between <QUALF> tags -- like 
this: <QUALF>012</QUALF>.

I'm not sure my perl-fu is that good.

Any clues on approach?

Alternative approaches?

Alternative approaches that can be quickly implemented?


[I'm using a Win2k box with a 1 or 2 year old version of perl sitting 
on it.]

Thanks,

RonL.


More information about the thelist mailing list