+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)
+ {
+ node = m_docNode->GetChildren();
+ wxXmlNode *prev = NULL;
+ while (node != NULL && node->GetType() != wxXML_ELEMENT_NODE)
+ {
+ prev = node;
+ node = node->GetNext();
+ }
+ if (node && root)
+ {
+ root->SetNext( node->GetNext() );
+ wxDELETE(node);
+ }
+ if (prev)
+ prev->SetNext(root);
+ else
+ m_docNode->SetChildren(root);
+ }
+ else
+ {
+ m_docNode = new wxXmlNode(wxXML_DOCUMENT_NODE, wxEmptyString);
+ m_docNode->SetChildren(root);
+ }
+ if (root)
+ root->SetParent(m_docNode);
+}
+
+void wxXmlDocument::AppendToProlog(wxXmlNode *node)
+{
+ if (!m_docNode)
+ m_docNode = new wxXmlNode(wxXML_DOCUMENT_NODE, wxEmptyString);
+ if (IsOk())
+ m_docNode->InsertChild( node, GetRoot() );
+ else
+ m_docNode->AddChild( node );
+}