1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxXmlDocument documentation
4 %% Author: Francesco Montorsi
7 %% Copyright: (c) 2006 Francesco Montorsi
8 %% License: wxWindows license
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{\class{wxXmlDocument
}}\label{wxxmldocument
}
13 This class holds XML data/
document as parsed by XML parser in the root node.
15 wxXmlDocument internally uses the expat library which comes with wxWidgets to parse the given stream.
17 A simple example of using XML classes is:
21 if (!doc.Load(wxT("myfile.xml"))
24 // start processing the XML file
25 if (doc.GetRoot()->GetName() != wxT("myroot-node"))
28 wxXmlNode *child = doc.GetRoot()->GetChildren();
31 if (child->GetName() == wxT("tag1"))
{
33 // process text enclosed by <tag1></tag1>
34 wxString content = child->GetNodeContent();
39 // process properties of <tag1>
40 wxString propvalue1 = child->GetPropVal(wxT("prop1"), wxT("default-value"));
41 wxString propvalue2 = child->GetPropVal(wxT("prop2"), wxT("default-value"));
45 } else if (child->GetName() == wxT("tag2"))
{
50 child = child->GetNext();
56 \wxheading{Derived from
}
58 \helpref{wxObject
}{wxobject
}
60 \wxheading{Include files
}
66 \helpref{wxXmlNode
}{wxxmlnode
},
\helpref{wxXmlProperty
}{wxxmlproperty
}
69 \latexignore{\rtfignore{\wxheading{Members
}}}
72 \membersection{wxXmlDocument::wxXmlDocument
}\label{wxxmldocumentwxxmldocument
}
74 \func{}{wxXmlDocument
}{\void}
77 \func{}{wxXmlDocument
}{\param{const wxString\&
}{filename
},
\param{const wxString\&
}{encoding = wxT("UTF-
8")
}}
79 Loads the given
{\it filename
} using the given encoding. See
\helpref{Load()
}{wxxmldocumentload
}.
81 \func{}{wxXmlDocument
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{encoding = wxT("UTF-
8")
}}
83 Loads the XML
document from given stream using the given encoding. See
\helpref{Load()
}{wxxmldocumentload
}.
85 \func{}{wxXmlDocument
}{\param{const wxXmlDocument\&
}{doc
}}
89 \membersection{wxXmlDocument::
\destruct{wxXmlDocument
}}\label{wxxmldocumentdtor
}
91 \func{}{\destruct{wxXmlDocument
}}{\void}
93 Virtual destructor. Frees the
document root node.
95 \membersection{wxXmlDocument::GetEncoding
}\label{wxxmldocumentgetencoding
}
97 \constfunc{wxString
}{GetEncoding
}{\void}
99 Returns encoding of in-memory representation of the
document
100 (same as passed to
\helpref{Load()
}{wxxmldocumentload
} or constructor, defaults to UTF-
8).
102 NB: this is meaningless in Unicode build where data are stored as wchar
\_t*.
105 \membersection{wxXmlDocument::GetFileEncoding
}\label{wxxmldocumentgetfileencoding
}
107 \constfunc{wxString
}{GetFileEncoding
}{\void}
109 Returns encoding of
document (may be empty).
111 Note: this is the encoding original file was saved in, *not* the
112 encoding of in-memory representation!
115 \membersection{wxXmlDocument::GetRoot
}\label{wxxmldocumentgetroot
}
117 \constfunc{wxXmlNode*
}{GetRoot
}{\void}
119 Returns the root node of the
document.
122 \membersection{wxXmlDocument::GetVersion
}\label{wxxmldocumentgetversion
}
124 \constfunc{wxString
}{GetVersion
}{\void}
126 Returns the version of
document.
127 This is the value in the
{\tt <?xml version="
1.0"?>
} header of the XML
document.
128 If the version property was not explicitely given in the header, this function
129 returns an empty string.
132 \membersection{wxXmlDocument::IsOk
}\label{wxxmldocumentisok
}
134 \constfunc{bool
}{IsOk
}{\void}
136 Returns
\true if the
document has been loaded successfully.
139 \membersection{wxXmlDocument::Load
}\label{wxxmldocumentload
}
141 \func{bool
}{Load
}{\param{const wxString\&
}{filename
},
\param{const wxString\&
}{encoding = wxT("UTF-
8")
}}
143 Parses
{\it filename
} as an xml
document and loads data. Returns
\true on success,
\false otherwise.
145 \func{bool
}{Load
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{encoding = wxT("UTF-
8")
}}
147 Like above but takes the data from given input stream.
149 \membersection{wxXmlDocument::Save
}\label{wxxmldocumentsave
}
151 \constfunc{bool
}{Save
}{\param{const wxString\&
}{filename
}}
153 Saves XML tree creating a file named with given string.
155 \constfunc{bool
}{Save
}{\param{wxOutputStream\&
}{stream
}}
157 Saves XML tree in the given output stream.
159 \membersection{wxXmlDocument::SetEncoding
}\label{wxxmldocumentsetencoding
}
161 \func{void
}{SetEncoding
}{\param{const wxString\&
}{enc
}}
163 Sets the enconding of the
document.
165 \membersection{wxXmlDocument::SetFileEncoding
}\label{wxxmldocumentsetfileencoding
}
167 \func{void
}{SetFileEncoding
}{\param{const wxString\&
}{encoding
}}
169 Sets the enconding of the file which will be used to save the
document.
171 \membersection{wxXmlDocument::SetRoot
}\label{wxxmldocumentsetroot
}
173 \func{void
}{SetRoot
}{\param{wxXmlNode*
}{node
}}
175 Sets the root node of this
document. Deletes previous root node.
177 \membersection{wxXmlDocument::SetVersion
}\label{wxxmldocumentsetversion
}
179 \func{void
}{SetVersion
}{\param{const wxString\&
}{version
}}
181 Sets the version of the XML file which will be used to save the
document.
183 \membersection{wxXmlDocument::operator=
}\label{wxxmldocumentoperatorassign
}
185 \func{wxXmlDocument\& operator
}{operator=
}{\param{const wxXmlDocument\&
}{doc
}}
187 Copies the given
document.