Leser: 10
5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
</server>
<server type="0x1" address="86.210.65.68" status="UP">
<hostname>86.210.65.68</hostname>
...
<name>Server.com</name>
<rules>
<rule name="protocol">7</rule>
...
<rule name="dedicated">1</rule>
<rule name="os">linux</rule>
</rules>
</server>
<server type...
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl -w use strict; use XML::Twig; my $twig = new XML::Twig( TwigRoots => { 'server' => \&output_srv }); $twig->parsefile("myfile.xml"); sub output_srv { my( $tree, $elem ) = @_; my $status = $elem->{att}->{'status'}, "\n"; my $hostname = $elem->elt_id('hostname')->text || ''; my $os = $elem->elt_id('os')->text || ''; print "Host: $hostname Status: $status OS: $os\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl -w use strict; use XML::Twig; my $twig = new XML::Twig( TwigRoots => { 'server' => \&output_srv }); $twig->parsefile("myfile.xml"); sub output_srv { my( $tree, $elem ) = @_; my $status = $elem->att('status') . "\n"; my $hostname = $elem->findvalue('hostname') || ''; my $os = $elem->findvalue('rules/rule[@name="os"]') || ''; print "Host: $hostname Status: $status OS: $os\n"; }
5 Einträge, 1 Seite |