Looking for a Perl or (similar) type of script to parse XML files for errors

W

WBible

I'm looking for a Perl script ( or assistance on how to write one) for
performing a a pattern match in XML data files to search for the Error
message and match them w/ the actual offending data records. ie. The
error search string would be "Error system" which displays the
applicable error message immediately following. Ideally it would
redirect the errors messages to an output file w/ the data record ids
matched in a prompted XML tag.

Does anyone have something similar that I could use as a base? I
realize that grep will do some of this but it's a little more
difficult to parse given the length of the java error messages.

Thanks,

Will
 
W

Will

I'm looking for a Perl script ( or assistance on how to write one) for
http://groups.google.com/group/comp.lang.perl.misc/search?q=parse+xml...

Does anyone have something similar that I could use as a base? I
realize that grep will do some of this but it's a little more
difficult to parse given the length of the java error messages.

java?!?

Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

The app. was written in Java and produces an error file/log w/ the
error messages and the XML data section applied to it. I'm not a java
guy but are you asking if java is the way to go here? Thanks
 
I

Ian Wilson

It is my experience that, in this newsgroup, you are far more likely to
receive the latter than the former. The more effort you make in writing
some Perl, the more help you will get. Have a go.

Here Michele is pointing out that you can use Google to search for prior
discussion of this subject. Many people tire of repeating the same
advice over and over and over again.

The general answer to "how do I parse XML" is "Use a Perl module
designed for that purpose". You can find them in CPAN.
Does anyone have something similar that I could use as a base? I
realize that grep will do some of this but it's a little more
difficult to parse given the length of the java error messages.

java?!?

Michele -- {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map
substr (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Newsgroup tradition is to omit sigs from the text you are quoting.

The app. was written in Java and produces an error file/log w/ the
error messages and the XML data section applied to it.

Care to post a small sample?

I'm not a java guy but are you asking if java is the way to go here?
Thanks

My interpretation is that Michele was puzzled by your mention of Java.
It is likely that the programming language (used to create the program
that wrote the log) is irrelevant to your problem.

You probably could use Java to do what you want but if you're interested
in so doing you should take the question to a Java newsgroup.


Summary:
Use Google groups to search for prior discussion.
Look in CPAN for a module to parse XML.
Post a small sample of what you want to parse.
 
G

gf

I'm looking for a Perl script ( or assistance on how to write one) for
performing a a pattern match in XML data files to search for the Error
message and match them w/ the actual offending data records. ie. The
error search string would be "Error system" which displays the
applicable error message immediately following. Ideally it would
redirect the errors messages to an output file w/ the data record ids
matched in a prompted XML tag.

You might want to do a search for xml_grep on CPAN, which is part of
the XML::Twig module.

It has a --text-only option that makes it very convenient for parsing
XML from the command line and retrieving the content of the XML tag. I
use it to locate particular sections of XML configuration files from
bash shells and initialize variables in the shell script.

Otherwise, read through the source of xml_grep to see how they
implemented it in XML::Twig.

http://search.cpan.org/search?query=xml_grep
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top