From 4f3be7616729cbf0c8768caf861331d710d457a8 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Tue, 12 Jan 2016 20:41:37 -0800 Subject: 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. --- src/pugixml.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3