2006-04-30 07:37:12 -04:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: xmlnode.tex
%% Purpose: wxXmlNode documentation
%% Author: Francesco Montorsi
%% Created: 2006-04-18
%% RCS-ID: $Id$
%% Copyright: (c) 2006 Francesco Montorsi
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2006-03-11 08:43:58 -05:00
\section { \class { wxXmlNode} } \label { wxxmlnode}
Represents a node in an XML document. See \helpref { wxXmlDocument} { wxxmldocument} .
Node has a name and may have content
and properties. Most common node types are { \tt wxXML\_ TEXT\_ NODE} (name and
properties are irrelevant) and { \tt wxXML\_ ELEMENT\_ NODE} (e.g. in { \tt <title>hi</title>} there is
an element with name="title", irrelevant content and one child ({ \tt wxXML\_ TEXT\_ NODE}
with content="hi").
2006-04-30 07:37:12 -04:00
If \texttt { wxUSE\_ UNICODE} is 0, all strings are encoded in the encoding given to
\helpref { wxXmlDocument::Load} { wxxmldocumentload} (default is UTF-8).
2006-03-11 08:43:58 -05:00
\wxheading { Derived from}
No base class
\wxheading { Include files}
<wx/xml/xml.h>
\wxheading { Constants}
2006-04-30 07:37:12 -04:00
The following are the node types supported by \helpref { wxXmlNode} { wxxmlnode} :
2006-03-11 08:43:58 -05:00
{ \small
\begin { verbatim}
enum wxXmlNodeType
{
wxXML_ ELEMENT_ NODE,
wxXML_ ATTRIBUTE_ NODE,
wxXML_ TEXT_ NODE,
wxXML_ CDATA_ SECTION_ NODE,
wxXML_ ENTITY_ REF_ NODE,
wxXML_ ENTITY_ NODE,
wxXML_ PI_ NODE,
wxXML_ COMMENT_ NODE,
wxXML_ DOCUMENT_ NODE,
wxXML_ DOCUMENT_ TYPE_ NODE,
wxXML_ DOCUMENT_ FRAG_ NODE,
wxXML_ NOTATION_ NODE,
wxXML_ HTML_ DOCUMENT_ NODE
}
\end { verbatim}
}
\wxheading { See also}
\helpref { wxXmlDocument} { wxxmldocument} , \helpref { wxXmlProperty} { wxxmlproperty}
\latexignore { \rtfignore { \wxheading { Members} } }
\membersection { wxXmlNode::wxXmlNode} \label { wxxmlnodewxxmlnode}
2006-04-30 07:37:12 -04:00
\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 } }
2006-03-11 08:43:58 -05:00
\wxheading { Parameters}
2006-04-30 07:37:12 -04:00
\docparam { parent} { The parent node. Can be \NULL .}
2006-03-11 08:43:58 -05:00
\docparam { type} { One of the wxXmlNodeType enumeration value.}
\docparam { name} { The name of the node. This is the string which appears between angular brackets.}
\docparam { content} { The content of the node. Only meaningful when { \it type} is { \tt wxXML\_ TEXT\_ NODE} or { \tt wxXML\_ CDATA\_ SECTION\_ NODE} .}
2006-04-30 07:37:12 -04:00
\docparam { props} { If not \NULL , this wxXmlProperty object and its eventual siblings are attached to
2006-03-11 08:43:58 -05:00
the node.}
2006-04-30 07:37:12 -04:00
\docparam { next} { If not \NULL , this node and its eventual siblings are attached to
2006-03-11 08:43:58 -05:00
the node.}
\func { } { wxXmlNode} { \param { const wxXmlNode\& } { node} }
Copy constructor. Note that this does NOT copy syblings
2006-04-30 07:37:12 -04:00
and parent pointer, i.e. \helpref { GetParent()} { wxxmlnodegetparent} and \helpref { GetNext()} { wxxmlnodegetnext} will return \NULL
2006-03-11 08:43:58 -05:00
after using copy ctor and are never unmodified by operator=.
On the other hand, it DOES copy children and properties.
\func { } { wxXmlNode} { \param { wxXmlNodeType } { type} , \param { const wxString\& } { name} , \param { const wxString\& } { content = wxEmptyString} }
A simplified version of the first constructor form.
\membersection { wxXmlNode::\destruct { wxXmlNode} } \label { wxxmlnodedtor}
\func { } { \destruct { wxXmlNode} } { \void }
The virtual destructor. Deletes attached children and properties.
\membersection { wxXmlNode::AddChild} \label { wxxmlnodeaddchild}
\func { void} { AddChild} { \param { wxXmlNode* } { child} }
Adds the given node as child of this node. To attach a second children to this node, use the
\helpref { SetNext()} { wxxmlnodesetnext} function of the { \it child} node.
\membersection { wxXmlNode::AddProperty} \label { wxxmlnodeaddproperty}
\func { void} { AddProperty} { \param { const wxString\& } { name} , \param { const wxString\& } { value} }
Appends a property with given { \it name} and { \it value} to the list of properties for this node.
\func { void} { AddProperty} { \param { wxXmlProperty* } { prop} }
Appends the given property to the list of properties for this node.
\membersection { wxXmlNode::DeleteProperty} \label { wxxmlnodedeleteproperty}
\func { bool} { DeleteProperty} { \param { const wxString\& } { name} }
Removes the first properties which has the given { \it name} from the list of properties for this node.
\membersection { wxXmlNode::GetChildren} \label { wxxmlnodegetchildren}
2006-04-30 07:37:12 -04:00
\constfunc { wxXmlNode*} { GetChildren} { \param { void} { } }
2006-03-11 08:43:58 -05:00
Returns the first child of this node.
To get a pointer to the second child of this node (if it does exist), use the
\helpref { GetNext()} { wxxmlnodegetnext} function on the returned value.
\membersection { wxXmlNode::GetContent} \label { wxxmlnodegetcontent}
\constfunc { wxString} { GetContent} { \void }
Returns the content of this node. Can be an empty string.
2006-04-30 07:37:12 -04:00
Be aware that for nodes of type \texttt { wxXML_ ELEMENT_ NODE} (the most used node type) the
content is an empty string. See \helpref { GetNodeContent()} { wxxmlnodegetnodecontent} for more details.
\membersection { wxXmlNode::GetNodeContent} \label { wxxmlnodegetnodecontent}
\constfunc { wxString} { GetNodeContent} { \void }
Returns the content of the first child node of type \texttt { wxXML_ TEXT_ NODE} or \texttt { wxXML_ CDATA_ SECTION_ NODE} .
This function is very useful since the XML snippet \texttt { ``<tagname>tagcontent</tagname>"} is represented by
expat with the following tag tree:
\begin { verbatim}
wxXML_ ENTITY_ NODE name="tagname", content=""
|-- wxXML_ TEXT_ NODE name="", content="tagcontent"
\end { verbatim}
or eventually:
\begin { verbatim}
wxXML_ ENTITY_ NODE name="tagname", content=""
|-- wxXML_ CDATA_ SECTION_ NODE name="", content="tagcontent"
\end { verbatim}
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.
2006-03-11 08:43:58 -05:00
\membersection { wxXmlNode::GetName} \label { wxxmlnodegetname}
\constfunc { wxString} { GetName} { \void }
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} ).
\membersection { wxXmlNode::GetNext} \label { wxxmlnodegetnext}
\constfunc { wxXmlNode*} { GetNext} { \void }
2006-04-30 07:37:12 -04:00
Returns a pointer to the sibling of this node or \NULL if there are no siblings.
2006-03-11 08:43:58 -05:00
\membersection { wxXmlNode::GetParent} \label { wxxmlnodegetparent}
\constfunc { wxXmlNode*} { GetParent} { \void }
2006-04-30 07:37:12 -04:00
Returns a pointer to the parent of this node or \NULL if this node has no parent.
2006-03-11 08:43:58 -05:00
\membersection { wxXmlNode::GetPropVal} \label { wxxmlnodegetpropval}
\constfunc { bool} { GetPropVal} { \param { const wxString\& } { propName} , \param { wxString* } { value} }
Returns \true if a property named { \it propName} could be found.
2006-04-30 07:37:12 -04:00
If the { \it value} pointer is not \NULL , the value of that property is saved there.
2006-03-11 08:43:58 -05:00
\constfunc { wxString} { GetPropVal} { \param { const wxString\& } { propName} , \param { const wxString\& } { defaultVal} }
Returns the value of the property named { \it propName} if it does exist.
If it does not exist, the { \it defaultVal} is returned.
\membersection { wxXmlNode::GetProperties} \label { wxxmlnodegetproperties}
2006-04-30 07:37:12 -04:00
\constfunc { wxXmlProperty *} { GetProperties} { \void }
2006-03-11 08:43:58 -05:00
Return a pointer to the first property of this node.
\membersection { wxXmlNode::GetType} \label { wxxmlnodegettype}
\constfunc { wxXmlNodeType} { GetType} { \void }
Returns the type of this node.
\membersection { wxXmlNode::HasProp} \label { wxxmlnodehasprop}
\constfunc { bool} { HasProp} { \param { const wxString\& } { propName} }
Returns \true if this node has a property named { \it propName} .
\membersection { wxXmlNode::InsertChild} \label { wxxmlnodeinsertchild}
\func { void} { InsertChild} { \param { wxXmlNode* } { child} , \param { wxXmlNode* } { before\_ node} }
Inserts the { \it child} node after { \it before\_ node} in the children list.
\membersection { wxXmlNode::RemoveChild} \label { wxxmlnoderemovechild}
\func { bool} { RemoveChild} { \param { wxXmlNode* } { child} }
Removes the given node from the children list. Returns \true if the node was found and removed
or \false if the node could not be found.
\membersection { wxXmlNode::SetChildren} \label { wxxmlnodesetchildren}
\func { void} { SetChildren} { \param { wxXmlNode* } { child} }
Sets as first child the given node. The caller is responsible to delete any previously present
children node.
\membersection { wxXmlNode::SetContent} \label { wxxmlnodesetcontent}
\func { void} { SetContent} { \param { const wxString\& } { con} }
Sets the content of this node.
\membersection { wxXmlNode::SetName} \label { wxxmlnodesetname}
\func { void} { SetName} { \param { const wxString\& } { name} }
Sets the name of this node.
\membersection { wxXmlNode::SetNext} \label { wxxmlnodesetnext}
\func { void} { SetNext} { \param { wxXmlNode* } { next} }
Sets as sibling the given node. The caller is responsible to delete any previously present
sibling node.
\membersection { wxXmlNode::SetParent} \label { wxxmlnodesetparent}
\func { void} { SetParent} { \param { wxXmlNode* } { parent} }
Sets as parent the given node. The caller is responsible to delete any previously present
parent node.
\membersection { wxXmlNode::SetProperties} \label { wxxmlnodesetproperties}
\func { void} { SetProperties} { \param { wxXmlProperty* } { prop} }
Sets as first property the given wxXmlProperty object.
The caller is responsible to delete any previously present properties attached to this node.
\membersection { wxXmlNode::SetType} \label { wxxmlnodesettype}
\func { void} { SetType} { \param { wxXmlNodeType } { type} }
Sets the type of this node.
\membersection { wxXmlNode::operator=} \label { wxxmlnodeoperatorassign}
2006-04-30 07:37:12 -04:00
\func { wxXmlNode\& } { operator=} { \param { const wxXmlNode\& } { node} }
2006-03-11 08:43:58 -05:00
See the copy constructor for more info.