aroso has asked for the wisdom of the Perl Monks concerning the following question:

Hi...
I can find in a xml file some tags. To do this i use the following script:
#!C:/server/Perl/bin/perl.exe use strict; use XML::Parser; my $parser = new XML::Parser(ErrorContext => 2); $parser->setHandlers(Char => \&char_handler, Default => \&default_handler); $parser->parsefile('xml_teste1.xml'); sub char_handler { # This is just here to reduce the noise seen by # the default handler } # End of char_handler sub default_handler { my ($p, $data) = @_; if ($data =~ /^Entity id/) { my $line = $p->current_line; $data =~ s/\n/\n\t/g; print "$line:\t$data\n"; } } # End of default_handler
This script find the tags that i can. But i need the content between the tags.
Someone can help me?

Title edit by tye

Replies are listed 'Best First'.
Re: XML::Parser
by davorg (Chancellor) on Jul 28, 2003 at 11:31 UTC

    Character data is handled by the character handler. You'll need to add some code to char_handler.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: XML::Parser
by liz (Monsignor) on Jul 28, 2003 at 12:28 UTC
    This was also posted verbatim on the Perl XML list. At almost exactly the same time.

    I'm wondering if this is good, acceptable or bad behavior.

    Liz

      I'm wondering if this is good, acceptable or bad behavior.

      That someone posted in question in two places you mean?

      Why would it be unacceptable behaviour? I'm just curious as I must be missing your point.

      -- vek --
        That someone posted in question in two places you mean?

        Sorry I wasn't clear. I should have emphasized at the same time. If the question had been placed on PerlMonks after receiving no answers from the Perl XML list, or vice-versa, it would be more acceptable to me.

        Now it looks like someone who needs a quick answer without putting (any|a lot) of effort into it themselves. Cross-posting on Usenet is generally not an acceptable practice.

        Liz

        A reply falls below the community's threshold of quality. You may see it by logging in.