Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/leethomason/tinyxml2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Thomason <leethomason@gmail.com>2020-12-30 21:18:16 +0300
committerGitHub <noreply@github.com>2020-12-30 21:18:16 +0300
commit11376382faf2a95a94f2bef65ef5e27b64b43af2 (patch)
tree90323990f03af6ef41fae1b2533e7d8e900142cc
parent8e1af3a7f95fbdea7fa664f868ba2e83d5833e83 (diff)
parentd59fd15db63aa93d979a4252dbea318116b194c9 (diff)
Merge pull request #840 from dota17/master
skip comment node before get text
-rwxr-xr-xtinyxml2.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 13b5ce0..20edfae 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -1655,8 +1655,18 @@ float XMLElement::FloatAttribute(const char* name, float defaultValue) const
const char* XMLElement::GetText() const
{
- if ( FirstChild() && FirstChild()->ToText() ) {
- return FirstChild()->Value();
+ /* skip comment node */
+ const XMLNode* node = FirstChild();
+ while (node) {
+ if (node->ToComment()) {
+ node = node->NextSibling();
+ continue;
+ }
+ break;
+ }
+
+ if ( node && node->ToText() ) {
+ return node->Value();
}
return 0;
}