[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-xml
Subject: Don't translate the entities
From: Aitor Soroa <aitors2002 () softhome ! net>
Date: 2004-09-08 12:14:37
Message-ID: 20040908121437.GB654 () sipc87 ! si ! ehu ! es
[Download RAW message or body]
Hi,
i am trying to parse, process and create XML files with XML::SAX. Suppose
this simple example:
**************
#!/usr/bin/perl
use strict;
use XML::SAX;
use XML::SAX::Writer;
require MyHandler;
my @buff;
die "Can't open $ARGV[0]" unless -e ($ARGV[0]);
my $w = XML::SAX::Writer->new();
my $handler = new MyHandler(Handler=>$w);
my $p = XML::SAX::ParserFactory->parser(Handler => $handler);
$p->parse_uri($ARGV[0]);
**************
and MyHandler.pm looks like:
*************
package MyHandler;
use base qw(XML::SAX::Base);
use Carp;
use strict;
use Data::Dumper;
sub new {
my $type = shift;
my %options = @_;
return bless \%options, $type;
}
sub start_document {
my ($self, $doc) = @_;
$self->{Handler}->start_document($doc);
}
sub start_element {
my ($self, $el) = @_;
$self->{Handler}->start_element($el);
}
sub end_element {
my ($self, $el) = @_;
$self->{Handler}->end_element($el);
}
sub characters {
my ($self, $el) = @_;
$self->{Handler}->characters($el);
}
sub end_document {
my ($self, $doc) = @_;
$self->{Handler}->end_document($doc);
}
1;
*************
The example donesn't do anything and writes a XML file to the screen using
the XML::SAX::Writer module. The problem is that the entities are translated
to whathever encoding, but i want them to be untouched. So, if the entry is:
<text>This character is a ñ</text>
the program produces:
<text>This character is a ñ</text>
but i want the same original:
<text>This character is a ñ</text>
so, how can i make for not translating the entities ?
Thank you in advance
aitor
_______________________________________________
Perl-XML mailing list
Perl-XML@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic