X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4c43dd9078b2f9f8bb280020a878932272d0163e..cec5ffc46da1cf66cb3e61567006a8c0f4b84f81:/docs/latex/wx/xmldocument.tex diff --git a/docs/latex/wx/xmldocument.tex b/docs/latex/wx/xmldocument.tex index 2428958038..c99bdae67c 100644 --- a/docs/latex/wx/xmldocument.tex +++ b/docs/latex/wx/xmldocument.tex @@ -1,9 +1,58 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Name: xmlnode.tex +%% Purpose: wxXmlDocument documentation +%% Author: Francesco Montorsi +%% Created: 2006-04-18 +%% RCS-ID: $Id$ +%% Copyright: (c) 2006 Francesco Montorsi +%% License: wxWindows license +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \section{\class{wxXmlDocument}}\label{wxxmldocument} This class holds XML data/document as parsed by XML parser in the root node. wxXmlDocument internally uses the expat library which comes with wxWidgets to parse the given stream. +A simple example of using XML classes is: + +\begin{verbatim} +wxXmlDocument doc; +if (!doc.Load(wxT("myfile.xml")) + return false; + +// start processing the XML file +if (doc.GetRoot()->GetName() != wxT("myroot-node")) + return false; + +wxXmlNode *child = doc.GetRoot()->GetChildren(); +while (child) { + + if (child->GetName() == wxT("tag1")) { + + // process text enclosed by + wxString content = child->GetNodeContent(); + + ... + + + // process properties of + wxString propvalue1 = child->GetPropVal(wxT("prop1"), wxT("default-value")); + wxString propvalue2 = child->GetPropVal(wxT("prop2"), wxT("default-value")); + + ... + + } else if (child->GetName() == wxT("tag2")) { + + // process tag2 ... + } + + child = child->GetNext(); +} +\end{verbatim} + + + \wxheading{Derived from} \helpref{wxObject}{wxobject} @@ -43,6 +92,17 @@ Copy constructor. Virtual destructor. Frees the document root node. + +\membersection{wxXmlDocument::DetachRoot}\label{wxxmldocumentdetachroot} + +\func{wxXmlNode*}{DetachRoot}{\void} + +Detaches the document root node and returns it. The document root node will be set to \NULL +and thus \helpref{IsOk}{wxxmldocumentisok} will return \false after calling this function. + +Note that the caller is reponsible for deleting the returned node in order to avoid memory leaks. + + \membersection{wxXmlDocument::GetEncoding}\label{wxxmldocumentgetencoding} \constfunc{wxString}{GetEncoding}{\void} @@ -124,6 +184,8 @@ Sets the enconding of the file which will be used to save the document. \func{void}{SetRoot}{\param{wxXmlNode* }{node}} Sets the root node of this document. Deletes previous root node. +Use \helpref{DetachRoot}{wxxmlnodedetachroot} and then SetRoot if you want to +replace the root node without deleting the old document tree. \membersection{wxXmlDocument::SetVersion}\label{wxxmldocumentsetversion}