Comments are not SimpleXML element children
- Comments should not be counted as node children Closes #863
Esse commit está contido em:
@@ -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)
|
||||
Referência em uma Nova Issue
Bloquear um usuário