ÓÃPERL ½âÎöxmlÎļþʱÓöµ½µÄÒ»¸öÎÊÌâ
ÎÒÔÚ×¼±¸ÓÃPerl½âÎöÒ»¸öxmlÎļþʱ,³ÌÐòÒ»ÔËÐоͱ¨Ò»¸ö´í:
Couldn't open encmap gb2312.enc:
No such file or directory
at C:/Perl/lib/XML/Parser.pm line 187
ÆäÖÐÎÒÓõ½µÄ°üÊÇXML::Simple.
ÏàÓ¦µÄ´úÂëÊÇ:
my $file =qq(1.xml);
my $xml =XMLin($file);
print $xml;
ÇëÎʸßÊÖÃÇ,ÕâÊÇʲôÎÊÌâµ¼ÖµÄ?Ó¦¸ÃÔõôȥ½â¾ö?лл.
Äã¼ì²éÒ»ÏÂÄãÒª½âÎöµÄxmlÎļþÊÇ·ñ¿ÉÒÔͨ¹ýÄã´«ÈëµÄ²ÎÊý¶ø·ÃÎʵ½.
ͨ¹ý²ÎÊý´«ÈëÒ²±¨Í¬ÑùµÄ´íÎó.
Perl code:
use strict;
use warnings;
use XML::Simple;
my $xml=XMLin('test.xml');
use Data::Dumper;
print Dumper($xml);
E:\temp> perl test.pl
$VAR1 = {
'debugfile ' => '/tmp/foo.debug ',
'server ' => {
'kalahari ' => {
'osversion ' => '2.0.34 ',
'osname ' => 'linux ',
Ïà¹ØÎÊ´ð£º
Êý¾Ý¿â±íÖÐÓÐÒ»ÁУ¨TranXml£©ÀàÐÍÊÇxml£¬´æ´¢µÄÊÇÀàËÆ
<fathernode>
<a>aaa
</a>
<b>bbb
</b>
</fathernode>
µÄÐÅÏ¢£¬²¢ÇÒͨ¹ý²éѯ·½· ......
<?xml version="1.0"?>
<root>
<status>433</status>
<msg>Õâ¸öÊǺº×Ö</msg>
<serialno>123</serialno>
</root>
ÈçºÎÓÃASP¶ÁÈ¡ statusÖµ ......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎͼ¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
ÎÒÒªÔÚÍøÒ³ÉÏÉÏ´«Ò»¸öXMLÎļþ£¬ÎÒÔÚC#ÖÐдÁËÒ»¸öÑéÖ¤XMLÎļþ¸ñʽµÄ·½·¨£º
private bool ValidateXml(string xmlFilePath)
{
string xsdPath = Request.PhysicalApp ......
ÏÂÃæÊÇXML³õʼÎļþÄÚÈÝ
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......