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

Discussion in 'Perl Misc' started by WBible@gmail.com, Apr 4, 2007.

  1. Guest

    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
     
    , Apr 4, 2007
    #1
    1. Advertising

  2. Will Guest

    On Apr 4, 5:43 pm, Michele Dondi <> wrote:
    > On 4 Apr 2007 13:27:38 -0700, wrote:
    >
    > >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
     
    Will, Apr 4, 2007
    #2
    1. Advertising

  3. Ian Wilson Guest

    Re: Looking for a Perl or (similar) type of script to parse XML filesfor errors

    Will wrote:
    > On Apr 4, 5:43 pm, Michele Dondi <> wrote:
    >
    >> On 4 Apr 2007 13:27:38 -0700, 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.lang.perl.misc/search?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.
     
    Ian Wilson, Apr 5, 2007
    #3
  4. gf Guest

    On Apr 4, 1:27 pm, 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
     
    gf, Apr 5, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,841
  2. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,007
    Mark Goldin
    Jan 17, 2004
  3. Ramon
    Replies:
    5
    Views:
    10,859
    John C. Bollinger
    Jan 3, 2005
  4. Cam
    Replies:
    3
    Views:
    144
    James Edward Gray II
    Jul 22, 2005
  5. Rebhan, Gilbert

    Parse csv similar file

    Rebhan, Gilbert, Feb 6, 2007, in forum: Ruby
    Replies:
    16
    Views:
    216
    Erik Veenstra
    Feb 7, 2007
Loading...

Share This Page