1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxXmlNode documentation
4 %% Author: Francesco Montorsi
7 %% Copyright: (c) 2006 Francesco Montorsi
8 %% License: wxWindows license
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{\class{wxXmlNode
}}\label{wxxmlnode
}
13 Represents a node in an XML
document. See
\helpref{wxXmlDocument
}{wxxmldocument
}.
15 Node has a name and may have content
16 and properties. Most common node types are
{\tt wxXML
\_TEXT\_NODE} (name and
17 properties are irrelevant) and
{\tt wxXML
\_ELEMENT\_NODE} (e.g. in
{\tt <title>hi</title>
} there is
18 an element with name="title", irrelevant content and one child (
{\tt wxXML
\_TEXT\_NODE}
21 If
\texttt{wxUSE
\_UNICODE} is
0, all strings are encoded in the encoding given to
22 \helpref{wxXmlDocument::Load
}{wxxmldocumentload
} (default is UTF-
8).
25 \wxheading{Derived from
}
29 \wxheading{Include files
}
35 The following are the node types supported by
\helpref{wxXmlNode
}{wxxmlnode
}:
44 wxXML_CDATA_SECTION_NODE,
45 wxXML_ENTITY_REF_NODE,
50 wxXML_DOCUMENT_TYPE_NODE,
51 wxXML_DOCUMENT_FRAG_NODE,
53 wxXML_HTML_DOCUMENT_NODE
60 \helpref{wxXmlDocument
}{wxxmldocument
},
\helpref{wxXmlProperty
}{wxxmlproperty
}
63 \latexignore{\rtfignore{\wxheading{Members
}}}
66 \membersection{wxXmlNode::wxXmlNode
}\label{wxxmlnodewxxmlnode
}
69 \func{}{wxXmlNode
}{\param{wxXmlNode*
}{parent
},
\param{wxXmlNodeType
}{type
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{content = wxEmptyString
},
\param{wxXmlProperty*
}{props =
\NULL},
\param{wxXmlNode*
}{next =
\NULL}}
71 \wxheading{Parameters
}
73 \docparam{parent
}{The parent node. Can be
\NULL.
}
74 \docparam{type
}{One of the wxXmlNodeType enumeration value.
}
75 \docparam{name
}{The name of the node. This is the string which appears between angular brackets.
}
76 \docparam{content
}{The content of the node. Only meaningful when
{\it type
} is
{\tt wxXML
\_TEXT\_NODE} or
{\tt wxXML
\_CDATA\_SECTION\_NODE}.
}
77 \docparam{props
}{If not
\NULL, this wxXmlProperty object and its eventual siblings are attached to
79 \docparam{next
}{If not
\NULL, this node and its eventual siblings are attached to
82 \func{}{wxXmlNode
}{\param{const wxXmlNode\&
}{node
}}
84 Copy constructor. Note that this does NOT copy syblings
85 and parent pointer, i.e.
\helpref{GetParent()
}{wxxmlnodegetparent
} and
\helpref{GetNext()
}{wxxmlnodegetnext
} will return
\NULL
86 after using copy ctor and are never unmodified by operator=.
88 On the other hand, it DOES copy children and properties.
91 \func{}{wxXmlNode
}{\param{wxXmlNodeType
}{type
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{content = wxEmptyString
}}
93 A simplified version of the first constructor form.
96 \membersection{wxXmlNode::
\destruct{wxXmlNode
}}\label{wxxmlnodedtor
}
98 \func{}{\destruct{wxXmlNode
}}{\void}
100 The virtual destructor. Deletes attached children and properties.
102 \membersection{wxXmlNode::AddChild
}\label{wxxmlnodeaddchild
}
104 \func{void
}{AddChild
}{\param{wxXmlNode*
}{child
}}
106 Adds the given node as child of this node. To attach a second children to this node, use the
107 \helpref{SetNext()
}{wxxmlnodesetnext
} function of the
{\it child
} node.
109 \membersection{wxXmlNode::AddProperty
}\label{wxxmlnodeaddproperty
}
111 \func{void
}{AddProperty
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{value
}}
113 Appends a property with given
{\it name
} and
{\it value
} to the list of properties for this node.
115 \func{void
}{AddProperty
}{\param{wxXmlProperty*
}{prop
}}
117 Appends the given property to the list of properties for this node.
119 \membersection{wxXmlNode::DeleteProperty
}\label{wxxmlnodedeleteproperty
}
121 \func{bool
}{DeleteProperty
}{\param{const wxString\&
}{name
}}
123 Removes the first properties which has the given
{\it name
} from the list of properties for this node.
125 \membersection{wxXmlNode::GetChildren
}\label{wxxmlnodegetchildren
}
127 \constfunc{wxXmlNode*
}{GetChildren
}{\void}
129 Returns the first child of this node.
130 To get a pointer to the second child of this node (if it does exist), use the
131 \helpref{GetNext()
}{wxxmlnodegetnext
} function on the returned value.
133 \membersection{wxXmlNode::GetContent
}\label{wxxmlnodegetcontent
}
135 \constfunc{wxString
}{GetContent
}{\void}
137 Returns the content of this node. Can be an empty string.
138 Be aware that for nodes of type
\texttt{wxXML
\_ELEMENT\_NODE} (the most used node type) the
139 content is an empty string. See
\helpref{GetNodeContent()
}{wxxmlnodegetnodecontent
} for more details.
142 \membersection{wxXmlNode::GetDepth
}\label{wxxmlnodegetdepth
}
144 \constfunc{int
}{GetDepth
}{\param{wxXmlNode*
}{grandparent = NULL
}}
146 Returns the number of nodes which separe this node from
{\tt grandparent
}.
148 This function searches only the parents of this node until it finds
{\tt grandparent
}
149 or the
\NULL node (which is the parent of non-linked nodes or the parent of a
150 \helpref{wxXmlDocument
}{wxxmldocument
}'s root node).
153 \membersection{wxXmlNode::GetNodeContent
}\label{wxxmlnodegetnodecontent
}
155 \constfunc{wxString
}{GetNodeContent
}{\void}
157 Returns the content of the first child node of type
\texttt{wxXML
\_TEXT\_NODE} or
\texttt{wxXML
\_CDATA\_SECTION\_NODE}.
158 This function is very useful since the XML snippet
\texttt{``<tagname>tagcontent</tagname>"
} is represented by
159 expat with the following tag tree:
162 wxXML_ENTITY_NODE name="tagname", content=""
163 |-- wxXML_TEXT_NODE name="", content="tagcontent"
169 wxXML_ENTITY_NODE name="tagname", content=""
170 |-- wxXML_CDATA_SECTION_NODE name="", content="tagcontent"
173 An empty string is returned if the node has no children of type
\texttt{wxXML
\_TEXT\_NODE} or
\texttt{wxXML
\_CDATA\_SECTION\_NODE}, or if the content of the first child of such types is empty.
176 \membersection{wxXmlNode::GetName
}\label{wxxmlnodegetname
}
178 \constfunc{wxString
}{GetName
}{\void}
180 Returns the name of this node. Can be an empty string (e.g. for nodes of type
{\tt wxXML
\_TEXT\_NODE} or
{\tt wxXML
\_CDATA\_SECTION\_NODE}).
182 \membersection{wxXmlNode::GetNext
}\label{wxxmlnodegetnext
}
184 \constfunc{wxXmlNode*
}{GetNext
}{\void}
186 Returns a pointer to the sibling of this node or
\NULL if there are no siblings.
188 \membersection{wxXmlNode::GetParent
}\label{wxxmlnodegetparent
}
190 \constfunc{wxXmlNode*
}{GetParent
}{\void}
192 Returns a pointer to the parent of this node or
\NULL if this node has no parent.
194 \membersection{wxXmlNode::GetPropVal
}\label{wxxmlnodegetpropval
}
196 \constfunc{bool
}{GetPropVal
}{\param{const wxString\&
}{propName
},
\param{wxString*
}{value
}}
198 Returns
\true if a property named
{\it propName
} could be found.
199 If the
{\it value
} pointer is not
\NULL, the value of that property is saved there.
201 \constfunc{wxString
}{GetPropVal
}{\param{const wxString\&
}{propName
},
\param{const wxString\&
}{defaultVal
}}
203 Returns the value of the property named
{\it propName
} if it does exist.
204 If it does not exist, the
{\it defaultVal
} is returned.
206 \membersection{wxXmlNode::GetProperties
}\label{wxxmlnodegetproperties
}
208 \constfunc{wxXmlProperty *
}{GetProperties
}{\void}
210 Return a pointer to the first property of this node.
212 \membersection{wxXmlNode::GetType
}\label{wxxmlnodegettype
}
214 \constfunc{wxXmlNodeType
}{GetType
}{\void}
216 Returns the type of this node.
219 \membersection{wxXmlNode::HasProp
}\label{wxxmlnodehasprop
}
221 \constfunc{bool
}{HasProp
}{\param{const wxString\&
}{propName
}}
223 Returns
\true if this node has a property named
{\it propName
}.
225 \membersection{wxXmlNode::InsertChild
}\label{wxxmlnodeinsertchild
}
227 \func{bool
}{InsertChild
}{\param{wxXmlNode*
}{child
},
\param{wxXmlNode*
}{before
\_node}}
229 Inserts the
{\it child
} node after
{\it before
\_node} in the children list.
230 If
{\it before
\_node} is
\NULL, then
{\it child
} is prepended to the list of children and
231 becomes the first child of this node.
232 Returns
\true if
{\it before
\_node} has been found and the
{\it child
} node has been inserted.
234 \membersection{wxXmlNode::IsWhitespaceOnly
}\label{wxxmlnodecontainsiswhitespaceonly
}
236 \constfunc{bool
}{IsWhitespaceOnly
}{\void}
238 Returns
\true if the content of this node is a string containing only whitespaces (spaces,
239 tabs, new lines, etc). Note that this function is locale-independent since the parsing of XML
240 documents must always produce the exact same tree regardless of the locale it runs under.
242 \membersection{wxXmlNode::RemoveChild
}\label{wxxmlnoderemovechild
}
244 \func{bool
}{RemoveChild
}{\param{wxXmlNode*
}{child
}}
246 Removes the given node from the children list. Returns
\true if the node was found and removed
247 or
\false if the node could not be found.
249 Note that the caller is reponsible for deleting the removed node in order to avoid memory leaks.
251 \membersection{wxXmlNode::SetChildren
}\label{wxxmlnodesetchildren
}
253 \func{void
}{SetChildren
}{\param{wxXmlNode*
}{child
}}
255 Sets as first child the given node. The caller is responsible to delete any previously present
258 \membersection{wxXmlNode::SetContent
}\label{wxxmlnodesetcontent
}
260 \func{void
}{SetContent
}{\param{const wxString\&
}{con
}}
262 Sets the content of this node.
264 \membersection{wxXmlNode::SetName
}\label{wxxmlnodesetname
}
266 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
268 Sets the name of this node.
270 \membersection{wxXmlNode::SetNext
}\label{wxxmlnodesetnext
}
272 \func{void
}{SetNext
}{\param{wxXmlNode*
}{next
}}
274 Sets as sibling the given node. The caller is responsible to delete any previously present
277 \membersection{wxXmlNode::SetParent
}\label{wxxmlnodesetparent
}
279 \func{void
}{SetParent
}{\param{wxXmlNode*
}{parent
}}
281 Sets as parent the given node. The caller is responsible to delete any previously present
284 \membersection{wxXmlNode::SetProperties
}\label{wxxmlnodesetproperties
}
286 \func{void
}{SetProperties
}{\param{wxXmlProperty*
}{prop
}}
288 Sets as first property the given wxXmlProperty object.
289 The caller is responsible to delete any previously present properties attached to this node.
291 \membersection{wxXmlNode::SetType
}\label{wxxmlnodesettype
}
293 \func{void
}{SetType
}{\param{wxXmlNodeType
}{type
}}
295 Sets the type of this node.
297 \membersection{wxXmlNode::operator=
}\label{wxxmlnodeoperatorassign
}
299 \func{wxXmlNode\&
}{operator=
}{\param{const wxXmlNode\&
}{node
}}
301 See the copy constructor for more info.