XML::Simple, XMLin()

前端之家收集整理的这篇文章主要介绍了XML::Simple, XMLin()前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


#!/usr/bin/perl -w 
use strict; 
use XML::Simple; 

my $text = <<xml; 
< ?xml version="1.0"? > 
<web-app> 
  <servlet> 
    <servlet-name>PHP</servlet-name> 
    <servlet-class>net.PHP.servlet</servlet-class> 
  </servlet> 
  <servlet-mapping> 
    <servlet-name>PHP</servlet-name> 
    <url-pattern>*.PHP</url-pattern> 
  </servlet-mapping> 
</web-app> 
xml 
my $x = XMLin($text); 
foreach my $tag(keys %$x) 
{       
   my %h = %{$$x{$tag}}; 
   foreach(keys %h) 
   {       
      print "$tag => "; 
      print "$_ => $h{$_}\n"; 
   } 
} 

exit 0; 
原文链接:https://www.f2er.com/xml/295205.html

猜你在找的XML相关文章