skip comment node before get text
This commit is contained in:
14
tinyxml2.cpp
14
tinyxml2.cpp
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user