diff options
author | Lee Thomason <leethomason@gmail.com> | 2020-12-30 21:18:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-30 21:18:16 +0300 |
commit | 11376382faf2a95a94f2bef65ef5e27b64b43af2 (patch) | |
tree | 90323990f03af6ef41fae1b2533e7d8e900142cc | |
parent | 8e1af3a7f95fbdea7fa664f868ba2e83d5833e83 (diff) | |
parent | d59fd15db63aa93d979a4252dbea318116b194c9 (diff) |
Merge pull request #840 from dota17/master
skip comment node before get text
-rwxr-xr-x | tinyxml2.cpp | 14 |
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;
}
|