Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Looking for a Perl or (similar) type of script to parse XML files for errors

Reply
Thread Tools

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

 
 
WBible@gmail.com
Guest
Posts: n/a
 
      04-04-2007
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

 
Reply With Quote
 
 
 
 
Will
Guest
Posts: n/a
 
      04-04-2007
On Apr 4, 5:43 pm, Michele Dondi <(E-Mail Removed)> wrote:
> On 4 Apr 2007 13:27:38 -0700, (E-Mail Removed) wrote:
>
> >I'm looking for a Perl script ( or assistance on how to write one) for

>
> http://groups.google.com/group/comp....ch?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

 
Reply With Quote
 
 
 
 
Ian Wilson
Guest
Posts: n/a
 
      04-05-2007
Will wrote:
> On Apr 4, 5:43 pm, Michele Dondi <(E-Mail Removed)> wrote:
>
>> On 4 Apr 2007 13:27:38 -0700, (E-Mail Removed) wrote:
>>
>>> I'm looking for a Perl script ( or assistance on how to write
>>> one)


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.

>>
>> http://groups.google.com/group/comp....ch?q=parse+xml...
>>


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.
 
Reply With Quote
 
gf
Guest
Posts: n/a
 
      04-05-2007
On Apr 4, 1:27 pm, (E-Mail Removed) wrote:
> 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


 
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
Execute another perl script from my perl script Petterson Mikael Perl Misc 3 01-05-2005 01:31 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments