summaryrefslogtreecommitdiff
path: root/src/pugixml.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-01-12 20:41:37 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-01-12 20:41:37 -0800
commit4f3be7616729cbf0c8768caf861331d710d457a8 (patch)
tree2e4f67bf33ac0f4b982831b4cc31f61d50cec836 /src/pugixml.cpp
parent85238132d3e3029d0454d5e16222a7d48b26e381 (diff)
Preserve order semantics for child_value/text when using parse_embed_pcdata
The performance cost is probably negligible and this means we treat embedded value as the first child consistently.
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r--src/pugixml.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index f447e97..158a24d 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -5486,14 +5486,14 @@ namespace pugi
{
if (!_root) return PUGIXML_TEXT("");
- for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
- if (impl::is_text_node(i) && i->value)
- return i->value;
-
// element nodes can have value if parse_embed_pcdata was used
if (PUGI__NODETYPE(_root) == node_element && _root->value)
return _root->value;
+ for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
+ if (impl::is_text_node(i) && i->value)
+ return i->value;
+
return PUGIXML_TEXT("");
}
@@ -6237,14 +6237,14 @@ namespace pugi
{
if (!_root || impl::is_text_node(_root)) return _root;
- for (xml_node_struct* node = _root->first_child; node; node = node->next_sibling)
- if (impl::is_text_node(node))
- return node;
-
// element nodes can have value if parse_embed_pcdata was used
if (PUGI__NODETYPE(_root) == node_element && _root->value)
return _root;
+ for (xml_node_struct* node = _root->first_child; node; node = node->next_sibling)
+ if (impl::is_text_node(node))
+ return node;
+
return 0;
}