papo has asked for the wisdom of the Perl Monks concerning the following question:
If I save or print the modified xml, that declaration still is intact, however the actual file encoding changes to latin1. This even happens if I comment out all of the modifications and just parse the file. This reduces my code to:<?xml version = "1.0" encoding = "UTF-8"?>
My knowledge of perl is rather basic, I must be doing something utterly wrong here but unfortunately, I can't figure out what it is. I'm using perl 5.8.8 and XML::DOM 1.43.#!/usr/bin/perl use XML::DOM::XPath; use strict; use warnings; my $parser= XML::DOM::Parser->new(); my $srcdir=shift; my $dstdir=shift; opendir(SRC,$srcdir); foreach(grep (/\.xml$/,readdir(SRC))) { my $doc = $parser->parsefile("$srcdir/$_"); $doc->printToFile("$dstdir/$_"); $doc->dispose; } close(SRC);
Any hints are appreciated; thank you in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::DOM encodes in latin1 instead of UTF-8
by moritz (Cardinal) on Jun 18, 2008 at 21:46 UTC | |
|
Re: XML::DOM encodes in latin1 instead of UTF-8
by pc88mxer (Vicar) on Jun 18, 2008 at 21:46 UTC | |
|
Re: XML::DOM encodes in latin1 instead of UTF-8
by Your Mother (Archbishop) on Jun 18, 2008 at 22:00 UTC |