Comments are not SimpleXML element children

- Comments should not be counted as node children

Closes #863
Esse commit está contido em:
danslo
2013-07-18 10:29:14 -07:00
commit de Sara Golemon
commit 079dc468ca
3 arquivos alterados com 18 adições e 0 exclusões
+2
Ver Arquivo
@@ -165,6 +165,8 @@ static Array create_children(CResRef doc, xmlNodePtr root,
CStrRef ns, bool is_prefix) {
Array properties = Array::Create();
for (xmlNodePtr node = root->children; node; node = node->next) {
if (root->parent && root->parent->type == XML_DOCUMENT_NODE &&
node->type == XML_COMMENT_NODE) continue;
if (node->children || node->prev || node->next) {
if (node->type == XML_TEXT_NODE) {
// bad node from parser, ignoring it...
@@ -0,0 +1,14 @@
<?php
$element = simplexml_load_string(<<<EOF
<root>
<!-- I am a comment -->
<elem1>
<elem2 />
<!-- I am also a comment -->
</elem1>
</root>
EOF
);
var_dump($element->count());
var_dump($element->elem1->count());
@@ -0,0 +1,2 @@
int(1)
int(1)