[PerlChina] XML中文
Question
wanliyou at gmail.com
Tue Aug 12 20:13:06 PDT 2008
2008/8/13 Fayland Lam <fayland at gmail.com>
> Question wrote:
> > Hi,
> > 现在想用perl解析一个asx(xml)文件,现在用XML::DOM发现不支持中文。
>
> http://wiki.perlchina.org/index.php/Perl-XML-FAQ
>
> http://wiki.perlchina.org/index.php/%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8BPerl_XML%EF%BC%9A%E6%8E%A5%E5%8F%A3%E7%AF%87
>
> 一般来说,最好你去解析 utf8 的 xml 文件
> 如果需要解析 gb2312 的文件的话,下载
> http://www.fayland.org/misc/backup/gb2312.enc
> 找到 XML::Parser 的地址
>
> bash-3.00$ perldoc -l XML::Parser
> /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi/XML/Parser.pm
>
> 然后下载过去放到
>
> /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi/XML/Parser/Encodings/
> 下试试。
>
> Thanks.
>
谢谢各位,文件是这样的,asx文件
<asx version = "3.0">
<title>CCTV视频</title>
<abstract></abstract>
<copyright>XMLFDFFD</copyright>
<author>FREE</author>
<entry>
<title>CCTV视频</title>
<abstract></abstract>
<copyright>XMLFDFFD</copyright>
<author>FREE</author>
<STARTTIME VALUE="00:10:00" />
<DURATION VALUE="00:20:00" />
<ref href = "mms://201.174.195.1/abc.wmv"/>
</entry>
</asx>
我自己在前面加上<?xml version="1.0" encoding="UTF-8"?>
CCTV视频 加上cdata也是不行。
use XML::Parser;
my $parser = new XML::Parser();
$parser->parsefile("test\\test.asx");
--
>: ~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/china-pm/attachments/20080813/5a155869/attachment.html>
More information about the China-pm
mailing list