Re: Getting encoding declaration with XML::SAX
by A. Pollock other posts by this author
Feb 28 2006 3:29PM messages near this date
view in the new Beta List Site
Re: Getting encoding declaration with XML::SAX
|
Re: Getting encoding declaration with XML::SAX
& XSLT This works for me:
sub xml_decl {
my ($self, $data) = @_;
print $data-> {Encoding}, "\n";
}
Arvin
> ----- Original Message -----
> From: "Timothy Appnel" <tappnel@[...].com>
> To: perl-xml@[...].com
> Subject: Getting encoding declaration with XML::SAX
> Date: Tue, 28 Feb 2006 16:08:01 -0500
>
>
> I'm trying to write some code that will parse an XML document and
> optionally reserialize it back. I have to expect character sets other
> then utf-8 will be passed in. The problem I'm running into is getting
> the declared encoding out of the XML while parsing with XML::SAX.
> set_document_locator doesn't pick up the encoding declaration. I've
> tried a couple of different parsers and feeds with different
> encodings. Still no love. Here is a test script I'm running...
>
> #!/usr/bin/perl -w
> use strict;
>
> use XML::SAX::ParserFactory;
> my $handler = XML::SAX::Foo->new();
> my $p = XML::SAX::ParserFactory->parser(Handler => $handler);
> $p->parse_file('atom.xml'); # http://www.sixapart.jp/atom.xml
>
> package XML::SAX::Foo;
> use base qw( XML::SAX::Base );
>
> use Data::Dumper;
> sub set_document_locator { print Dumper(@_) }
>
> What am I do wrong here? Why is the declared encoding information so
> difficult to determine?
>
> <tim/>
> --
> Timothy Appnel
> http://www.timaoutloud.org/
>
> _______________________________________________
> Perl-XML mailing list
> Perl-XML@[...].com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
--
_______________________________________________
Search for businesses by name, location, or phone number. -Lycos Yellow Pages
http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Timothy Appnel
Dominic Mitchell
A. Pollock
Timothy Appnel
A. Pagaltzis
A. Pagaltzis
|