Merge pull request #840 from dota17/master
skip comment node before get text
This commit is contained in:
14
tinyxml2.cpp
14
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user