skip comment node before get text

This commit is contained in:
dota17
2020-10-22 15:16:34 +08:00
parent 1aeb57d26b
commit d59fd15db6

View File

@@ -1637,8 +1637,18 @@ float XMLElement::FloatAttribute(const char* name, float defaultValue) const
const char* XMLElement::GetText() const const char* XMLElement::GetText() const
{ {
if ( FirstChild() && FirstChild()->ToText() ) { /* skip comment node */
return FirstChild()->Value(); const XMLNode* node = FirstChild();
while (node) {
if (node->ToComment()) {
node = node->NextSibling();
continue;
}
break;
}
if ( node && node->ToText() ) {
return node->Value();
} }
return 0; return 0;
} }