[xml] xmlNodeGetContent() bug?



Hello,

 I found some strange behaviour of xmlNodeGetContent() function,
handling XML entities.
 For me it simply substitutes any XML entity reference node with empty
string instead of its value (however comments for this function in
libxml2 sources have these words: "Entity references are substituted").

 Here is example file (in PHP, but get_content() function have nothing
more then call of xmlNodeGetContent() in it)

<?php
$xml = xmldoc('<?xml version="1.0"?><root/>');
$root = $xml->root();
$root->append_child($xml->create_entity_reference('&#65;'));
$root->append_child($xml->create_text_node('text_1'));
$root->append_child($xml->create_entity_reference('&#66;'));
$root->append_child($xml->create_text_node('text_2'));
$root->append_child($xml->create_entity_reference('&#67;'));
echo $root->get_content();
?>

 This example returns me:

text_1text_2

 instead of expected:
Atext_1Btext_2C

 However dumping of same node returns expected:

&#65;text_1&#66;text_2&#67;

 And checking of <root> node childs shows, that there is 5 childs - 2
nodes and 3 entity references.

 Tested with versions 2.4.28 and 2.5.7 of libxml2 with same result.

 

 

-- 
Best regards,
 Alexander                          mailto:flying dom natm ru





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]