File: 33getnodetext.t

package info (click to toggle)
libxml-xpath-perl 1.48-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 608 kB
  • sloc: perl: 4,444; xml: 34; makefile: 10
file content (23 lines) | stat: -rw-r--r-- 505 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl

use strict;
use warnings;
use Test::More tests => 5;

BEGIN { use_ok 'XML::XPath' }

my $xp = XML::XPath->new(ioref => *DATA);
isa_ok($xp, 'XML::XPath');

my $text;
$text = $xp->getNodeText('//BBB[@id = "b1"]');
ok((defined $text), "text is defined for id that exists");
is($text, 'Foo');

$text = $xp->getNodeText('//BBB[@id = "b2"]');
ok((defined $text && ($text eq '')), "text is defined as '' (empty string) for id that does not exist");

__DATA__
<AAA>
<BBB id='b1'>Foo</BBB>
</AAA>