CC: | patp [...] bbn.com |
Subject: | Can't locate object method "_newForString" via XML::LibXML::Reader |
Date: | Thu, 07 Aug 2008 10:43:55 -0400 |
To: | bug-XML-LibXML [...] rt.cpan.org |
From: | Patrick Peterson <patp [...] bbn.com> |
Description: I can't get XML::LibXML::Reader->new() to work for location or string arguments. See example below. I may be missing something simple, because I can't get any of the examples from XML or CPAN sites to work.
Release: XML-LibXML-1.66
Show quoted text
>>>> perl -v
This is perl, v5.8.8 built for x86_64-linux-thread-multi
Show quoted text>>>> uname -a
Linux deltacb6.bbn.com 2.6.9-42.ELsmp #1 SMP Tue Aug 15 10:35:26 BST 2006 x86_64 x86_64 x86_64 GNU/Linux
Show quoted text>>>> cat testRead.pl
#!/usr/bin/perl
my $xml = <<'EOF';
<parent a='A' b='B'>
<child a='A' b='B'>
<gchild a='A' b='B'> a</gchild>
</child>
</parent>
EOF
use XML::LibXML;
use XML::LibXML::Reader;
my $r = XML::LibXML::Reader->new(string => $xml);
while ($r-> read) {
if ($r-> nodeType == XML_READER_TYPE_ELEMENT) {
print "-----------------\n";
print "Element ". $r-> name,"\n";
# several ways of reading attributes:
# read all attributes:
if ($r-> moveToFirstAttribute) {
do {{
print "Attribute ",$r-> name(), " => ",$r->value,"\n";
}} while ($r-> moveToNextAttribute);
$r-> moveToElement;
}
# back at the element
# ...
# read a specific attribute:
print "----\n";
print "Attribute b: ",$r-> getAttribute('b'),"\n";
}
}
__END__
Show quoted text>>>> testRead.pl
Can't locate object method "_newForString" via package "XML::LibXML::Reader" at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/XML/LibXML/Reader.pm line 159.
Thanks for your help, I love XML::LibXML.
Pat Peterson