Skip Menu |

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 14051
Status: rejected
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: sava [...] blueboard.biz
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.58_1
Fixed in: (no value)



Subject: findnodes() behaves strangely on elements that don't belong to a document
When findnodes() is called on an element that does not belong to a document, it changes the parent of element's children. This is demonstrated in the following little script: ----------------------------------------------------------------- #!/usr/bin/perl use strict; use XML::LibXML; my $tree = XML::LibXML::Element->new( 'tree' ); my $inbox = XML::LibXML::Element->new( 'tree_element' ); $tree->appendChild($inbox); #uncomment next 2 lines to prevent findnodes() from changing parent #my $doc = XML::LibXML::Document->new(); #$doc->setDocumentElement($tree); print STDERR "parent:", $inbox->parentNode()->nodeName(), " ", $inbox->parentNode(), "\n"; #comment next line to see what happens my ($res) = $tree->findnodes( "*[\@some_attr='something']" ); print STDERR "parent:", $inbox->parentNode()->nodeName(), " ", $inbox->parentNode(), "\n"; ----------------------------------------------------------------- The output of the script is something like: parent:tree XML::LibXML::Element=SCALAR(0x81e1370) parent:tree XML::LibXML::Element=SCALAR(0x81e13a0) and when finnodes() call is commented: parent:tree XML::LibXML::Element=SCALAR(0x81e1328) parent:tree XML::LibXML::Element=SCALAR(0x81e1328) However, if the element on which findnodes() is called belongs to a document, the parent is not changed. Tested with XML::LibXML 1.58_1 and libxml2-2.6.8, libxml2-2.6.12 and libxml2-2.6.20