Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLElement::SetText needs to skip any leading comments like XMLElement::GetText #927

Open
tomwjaw opened this issue Nov 24, 2022 · 0 comments

Comments

@tomwjaw
Copy link

tomwjaw commented Nov 24, 2022

If XMLElement has any leading comments before XMLText Child node a new XMLText Child node is created and added to the XMLElement instead of replacing the existing XMLText Child element.

Solution (replace existing with):

void XMLElement::SetText( const char* inText )
{
// [email protected] - Added missing skip comment node
XMLNode* node = FirstChild();
while(node) {
if(node->ToComment()) {
node = node->NextSibling();
continue;
}
break;
}
//if ( FirstChild() && FirstChild()->ToText() )
// FirstChild()->SetValue( inText );
if (node && node->ToText() )
node->SetValue( inText );
else {
XMLText* theText = GetDocument()->NewText( inText );
InsertFirstChild( theText );
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant