void wxXmlDocument::SetRoot(wxXmlNode *root)
{
+ if (root)
+ {
+ wxASSERT_MSG( root->GetType() == wxXML_ELEMENT_NODE,
+ "Can only set an element type node as root" );
+ }
+
wxXmlNode *node = m_docNode;
if (node)
{
prev = node;
node = node->GetNext();
}
- if (node)
+ if (node && root)
{
root->SetNext( node->GetNext() );
wxDELETE(node);
else
{
m_docNode = new wxXmlNode(wxXML_DOCUMENT_NODE, wxEmptyString);
+ m_docNode->SetChildren(root);
}
- root->SetParent(m_docNode);
+ if (root)
+ root->SetParent(m_docNode);
}
void wxXmlDocument::AppendToProlog(wxXmlNode *node)