- or download this
## The data:
<?xml version="1.0" encoding="iso-8859-1"?>
...
</server>
<server address="192.168.2.100" os="linux" type="conectiva" version=
+"9.0"/>
</hosts>
- or download this
my $xml = new XML::Simple();
my $tree = $xml->XMLin(DATA]);
my $addr0 = $tree->{hosts}{server}[0]{address}[0] ;
my $addr1 = $tree->{hosts}{server}[1]{address} ;
- or download this
my $XML = XML::Smart->new(DATA) ;
...
my $addr1 = $XML->{hosts}{server}[1]{address} ; ## return {addres
+s}
## ...or..
my $addr1 = $XML->{hosts}{server}[1]{address}[0] ; ## return {addre
+ss}
- or download this
my $addr = $XML->{hosts}{server}('type','eq','conectiva'){address} ;
- or download this
## Data:
<foo port="80">content<i>a</i><i>b</i></foo>
...
$HASH = (
foo => { i => ['a','b'] , CONTENT => 'content' }
);
- or download this
my $cont = $XML->{foo} ;
## ...or...
...
print "<<$cont>>\n" ; ## print: <<content>>
$content .= 'x' ; ## Append data.
- or download this
my $data = $XML->data ;
## Directly to the file:
my $data = $XML->save('new.xml') ;