Ask a Question related to PHP Bugs, Design and Development.
-
dave dot lane at gmx dot net #1
#39593 [Opn]: XPath NodeList: "Couldn't fetch DOMElement: Node no longer exists"
ID: 39593
User updated by: dave dot lane at gmx dot net
Reported By: dave dot lane at gmx dot net
Status: Open
Bug Type: DOM XML related
Operating System: Linux
PHP Version: 5.2.0
New Comment:
Sorry description should read:
Description:
------------
When the nodes in a NodeList that is the result of an XPath query are
copied into an array and returned from a function the Nodes in the
array although they exist are not valid. When the nodes in the array
are used a warning results: "Couldn't fetch DOMElement. Node no longer
exists..."
Previous Comments:
------------------------------------------------------------------------
[2006-11-22 17:54:18] dave dot lane at gmx dot net
Description:
------------
The following code does not work. When the nodes in a NodeList that is
the result of an XPath query are copied into an array and returned from
a function. When the nodes in the array are used a warning results:
"Couldn't fetch DOMElement. Node no longer exists..."
Reproduce code:
---------------
bug.php:
<?
$DOMMain =& OpenXMLDoc('main.xml');
$aArray =& GetArray($DOMMain);
echo 'After return: '.$aArray[0]->localName->localName."<br>\n";
function &OpenXMLDoc($sFileName) {
$DOM = new DOMDocument();
$DOM->preserveWhiteSpace = false;
$DOM->load($sFileName);
return $DOM;
}
function &ExecuteXPath($sXPath, DOMDocument &$DOMDocument, DOMNode
&$DOMNode) {
$objXPath = new DOMXPath($DOMDocument);
return $objXPath->query($sXPath, $DOMNode);
}
function &GetArray(&$DOMMain) {
$DOMInclude =& OpenXMLDoc('include.xml');
$NodeImported =
$DOMMain->importNode($DOMInclude->documentElement, true);
$NodeListImported =& ExecuteXPath('./include1', $DOMMain,
$NodeImported);
$NodeListImported = $NodeListImported->item(0)->childNodes;
echo 'In NodeList:
'.$NodeListImported->item(0)->localName."<br>\n";
$aArray = array();
foreach($NodeListImported as $Node) {
$aArray[] = $Node;
}
echo 'In Array: '.$aArray[0]->localName."<br>\n";
return $aArray;
}
?>
main.xml:
<?xml version = "1.0" encoding="ISO-8859-1"?>
<root>
</root>
include.xml:
<?xml version = "1.0" encoding="ISO-8859-1"?>
<include>
<include1>
<div>
<span>test</span>
</div>
</include1>
</include>
Expected result:
----------------
In NodeList: div
In Array: div
After return: div
Actual result:
--------------
In NodeList: div
In Array: div
Warning: Couldn't fetch DOMElement. Node no longer exists in
/var/www/html/usr/dla/csc/V2/bug/bug.php on line 5
After return:
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=39593&edit=1[/url]
dave dot lane at gmx dot net Guest
-
#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
ID: 36795 Comment by: philippe dot levan_nospam at kitpages dot fr Reported By: john at carney dot id dot au Status: ... -
#39593 [NEW]: XPath NodeList: "Couldn't fetch DOMElement: Node no longer exists"
From: dave dot lane at gmx dot net Operating system: Linux PHP version: 5.2.0 PHP Bug Type: DOM XML related Bug description:... -
SOLVED: Can't call method "FETCH" on an undefined value at /path/to/my/Cookie.pm
Pete Harlan posted a problem and workaround for a problem in a moderated Debian newsgroup (though this issue is not really related to Debian... -
SelectSingeNode("xpath")...how to test if null?
Hi, I'm using Dim xDoc as XmlDocument Dim xElem As xmlElement = xDoc("xpath") I then assign a variable to a value from the result node: Dim r... -
"Error: Bad node links. 5d'1 prev 5c != 5b" When I run oncheck -ci
When I run concheck -ci Informix send me an error in an index, with following message: Error: Bad node links. 5d'1 prev 5c != 5b What's...



Reply With Quote

