1
2
3
4
5
6
7
8
9
10
<opt>
<tables>
<section name="blubb" index="1">
<top>irgendein text</top>
<row id="">irgendein text</row>
</section>
<section name="bla" index="0">
</section>
</tables>
</opt>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$VAR1 = {
'tables' => {
'section' => {
'blubb' => {
'index' => '1',
'top' => 'irgendein text',
'row' => {
'content' => 'irgendein text',
'id' => ''
}
},
'bla' => {
'index' => '0'
}
}
}
};
1
2
3
4
5
6
7
8
<opt>
<tables name="section">
<bla index="0" />
<blubb index="1" top="irgendein text">
<row id="">irgendein text</row>
</blubb>
</tables>
</opt>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$VAR1 = {
'tables' => {
'blubb' => {
'index' => '1',
'top' => 'irgendein text',
'row' => {
'content' => 'irgendein text',
'id' => ''
}
},
'bla' => {
'index' => '0'
},
'name' => 'section'
}
};
XMLin(...,KeyAttr => [], ValueAttr => [], VarAttr => '')
1
2
3
4
5
6
7
8
9
10
11
12
#/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
use XML::LibXML::Node; # nur um zu zeigen was passiert, normal lass ich das weg
----------
Erzeugt Fehler:
Can't locate XML/LibXML/Node.pm in @INC (C:/Perl/site/lib C:/Perl/lib) at C:\Xitami\cgi-bin\test.pl line 6.
BEGIN failed--compilation aborted at C:\Xitami\cgi-bin\test.pl line 6.
use XML::LibXML; # REICHT VÖLLIG AUS
1 2 3 4
#-------------------------------------------------------------------------# # XML::LibXML::Node Interface # #-------------------------------------------------------------------------# package XML::LibXML::Node;
1 2 3
use XML::LibXML::Error; use XML::LibXML::NodeList; use XML::LibXML::XPathContext;
1
2
3
4
5
6
7
8
9
10
11
12
13
use XML::LibXML;
my $isbn = '076455106X';
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file('test.xml');
my $query = "//book[isbn = '$isbn']/pages/text()";
my($node) = $doc->findnodes($query);
$node->setData('394');
print $doc->toString;
1 2 3
my($node) = $doc->findnodes($query); die("Node not found") unless($node); $node->setData('394');