ã¨ã³ããªã¼ãæ¸ãã¦ãéä¸ã«è§£æ±ºãã¾ãããã¡ã¢ã£ã¦ããã¾ãã
use XML::Simple; use Data::Dumper; my $xml = <<'XML'; <a> <b> <c> <d> </d> </c> </b> </a> XML $\ = "\n"; print $xml; my $obj = XMLin($xml); # XMLãå ¥åã㦠print Dumper($obj); # ä¸èº«ã確èªãã print XMLout( $obj, NoAttr => 1, RootName => 'a' ); # XMLã¨ãã¦åºåãã¦ã¿ã
ãå®è¡ãã¦ã¿ãã¨ã
<a> <b> <c> <d> </d> </c> </b> </a> $VAR1 = { 'b' => { 'c' => { 'd' => {} } } }; <a> <b> <name>c</name> <d></d> </b> </a>
ã¨ãªããã§ãããããæ©ãã§ãããã ãã©ãããªãã¸ã§ã¯ãã®æ®µéã§ãï¼ã«ã¼ã以å¤ã®ï¼åç¬ã®ããã·ã¥ãªãã¡ã¬ã³ã¹ãé
åãªãã¡ã¬ã³ã¹ã§å
ã¾ãã¦ããããã«ããã°ããã¿ãããï¼XMLinã®å ´åã¯my $obj = XMLin($xml, ForceArray=>1)ã¨ãããï¼
æã£ãéãã®ï¼å¸¸èçãªï¼åãã«ãããå ´åã¯ã
- XMLinã«ã¯ForceArray=>1ãä»ãã
- ãªãã¸ã§ã¯ãå ã«åç¬ã®ããã·ã¥ãªãã¡ã¬ã³ã¹ãç¾ããªãããã«ããï¼ä¸è¨ãè¡ãªã£ãå ´åã¯ãããªã£ã¦ããï¼
- XMLoutã«ã¯NoAttr=>1ã¨RootName=>'ã«ã¼ãå'ãä»ãããï¼ããããªããã°anonè¦ç´ ããoptè¦ç´ ãããåºç¾ããå ´åãããï¼
ãå¿ãããã°è¯ãããã