lfast has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, Does anyone have a guess why this code generates an unblessed reference error? Code and output below. The output of Data::Dump seems to show that $nodes is blessed however I get the unblessed error at the end of the listing. Thanks, Larry # Test XML::DOM::Lite use strict "vars"; use strict "subs"; use XML::DOM::Lite qw(Parser :constants XPath); use XML::DOM::Lite::NodeList; use XML::Dumper; use Data::Dumper; my $xml = q| <perldata> <hello> </hello> </perldata> |; my $doc = Parser->parse($xml); my $nodes = $doc->selectNodes('/perldata/hello'); $Data::Dumper::Maxdepth=3; print Data::Dumper->Dump($nodes); my $len = $nodes->length; -------------------------------- node dump $VAR1 = bless( { 'nodeType' => 1, 'childNodes' => bless( [ 'XML::DOM::Lite::Node=HASH(0x1f43be4)' ], 'XML::DOM::Lite::NodeList' ), 'ownerDocument' => bless( { 'nodeType' => 9, 'elements' => 'HASH(0x1f432a4)', 'childNodes' => 'XML::DOM::Lite::NodeList=ARRAY(0x1f434d4)', 'nodeName' => '#document', 'documentElement' => 'XML::DOM::Lite::Node=HASH(0x1f439e4)', 'attributes' => 'XML::DOM::Lite::NodeList=ARRAY(0x1f43524)' }, 'XML::DOM::Lite::Document' ), 'nodeName' => 'hello', 'attributes' => bless( [], 'XML::DOM::Lite::NodeList' ), 'parentNode' => $VAR1->{'ownerDocument'}{'documentElement'}, 'tagName' => 'hello' }, 'XML::DOM::Lite::Node' ); Can't call method "length" on unblessed reference at test.pl line 26.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML lite unblessed reference
by Anonymous Monk on Aug 04, 2011 at 06:23 UTC | |
|
Re: XML lite unblessed reference
by wind (Priest) on Aug 05, 2011 at 02:07 UTC | |
by Anonymous Monk on Aug 05, 2011 at 03:49 UTC | |
by lfast (Initiate) on Aug 08, 2011 at 16:31 UTC | |
by Anonymous Monk on Aug 08, 2011 at 21:52 UTC |