Contents Up Previous Next

wxXmlNode

Represents a node in an XML document. See wxXmlDocument.

Node has a name and may have content and properties. Most common node types are wxXML_TEXT_NODE (name and properties are irrelevant) and wxXML_ELEMENT_NODE (e.g. in <title>hi</title> there is an element with name="title", irrelevant content and one child (wxXML_TEXT_NODE with content="hi").

If wxUSE_UNICODE is 0, all strings are encoded in the encoding given to Load (default is UTF-8).

Derived from

No base class

Include files

<wx/xml/xml.h>

Constants

The following are the node types supported by wxXmlNode:

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
}

See also

wxXmlDocument, wxXmlProperty

Members

wxXmlNode::wxXmlNode
wxXmlNode::~wxXmlNode
wxXmlNode::AddChild
wxXmlNode::AddProperty
wxXmlNode::DeleteProperty
wxXmlNode::GetChildren
wxXmlNode::GetContent
wxXmlNode::GetName
wxXmlNode::GetNext
wxXmlNode::GetParent
wxXmlNode::GetPropVal
wxXmlNode::GetProperties
wxXmlNode::GetType
wxXmlNode::HasProp
wxXmlNode::InsertChild
wxXmlNode::RemoveChild
wxXmlNode::SetChildren
wxXmlNode::SetContent
wxXmlNode::SetName
wxXmlNode::SetNext
wxXmlNode::SetParent
wxXmlNode::SetProperties
wxXmlNode::SetType
wxXmlNode::operator=


wxXmlNode::wxXmlNode

wxXmlNode(wxXmlNode* parent, wxXmlNodeType type, const wxString& name, const wxString& content = wxEmptyString, wxXmlProperty* props = NULL, wxXmlNode* next = NULL)

Parameters

parent

type name content props next

wxXmlNode(const wxXmlNode& node)

Copy constructor. Note that this does NOT copy syblings and parent pointer, i.e. GetParent() and GetNext() will return NULL after using copy ctor and are never unmodified by operator=.

On the other hand, it DOES copy children and properties.

wxXmlNode(wxXmlNodeType type, const wxString& name, const wxString& content = wxEmptyString)

A simplified version of the first constructor form.


wxXmlNode::~wxXmlNode

~wxXmlNode()

The virtual destructor. Deletes attached children and properties.


wxXmlNode::AddChild

void AddChild(wxXmlNode* child)

Adds the given node as child of this node. To attach a second children to this node, use the SetNext() function of the child node.


wxXmlNode::AddProperty

void AddProperty(const wxString& name, const wxString& value)

Appends a property with given name and value to the list of properties for this node.

void AddProperty(wxXmlProperty* prop)

Appends the given property to the list of properties for this node.


wxXmlNode::DeleteProperty

bool DeleteProperty(const wxString& name)

Removes the first properties which has the given name from the list of properties for this node.


wxXmlNode::GetChildren

wxXmlNode* GetChildren() const

Returns the first child of this node. To get a pointer to the second child of this node (if it does exist), use the GetNext() function on the returned value.


wxXmlNode::GetContent

wxString GetContent() const

Returns the content of this node. Can be an empty string.


wxXmlNode::GetName

wxString GetName() const

Returns the name of this node. Can be an empty string (e.g. for nodes of type wxXML_TEXT_NODE or wxXML_CDATA_SECTION_NODE).


wxXmlNode::GetNext

wxXmlNode* GetNext() const

Returns a pointer to the sibling of this node or NULL if there are no siblings.


wxXmlNode::GetParent

wxXmlNode* GetParent() const

Returns a pointer to the parent of this node or NULL if this node has no parent.


wxXmlNode::GetPropVal

bool GetPropVal(const wxString& propName, wxString* value) const

Returns true if a property named propName could be found. If the value pointer is not NULL, the value of that property is saved there.

wxString GetPropVal(const wxString& propName, const wxString& defaultVal) const

Returns the value of the property named propName if it does exist. If it does not exist, the defaultVal is returned.


wxXmlNode::GetProperties

wxXmlProperty* GetProperties() const

Return a pointer to the first property of this node.


wxXmlNode::GetType

wxXmlNodeType GetType() const

Returns the type of this node.


wxXmlNode::HasProp

bool HasProp(const wxString& propName) const

Returns true if this node has a property named propName.


wxXmlNode::InsertChild

void InsertChild(wxXmlNode* child, wxXmlNode* before_node)

Inserts the child node after before_node in the children list.


wxXmlNode::RemoveChild

bool RemoveChild(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.


wxXmlNode::SetChildren

void SetChildren(wxXmlNode* child)

Sets as first child the given node. The caller is responsible to delete any previously present children node.


wxXmlNode::SetContent

void SetContent(const wxString& con)

Sets the content of this node.


wxXmlNode::SetName

void SetName(const wxString& name)

Sets the name of this node.


wxXmlNode::SetNext

void SetNext(wxXmlNode* next)

Sets as sibling the given node. The caller is responsible to delete any previously present sibling node.


wxXmlNode::SetParent

void SetParent(wxXmlNode* parent)

Sets as parent the given node. The caller is responsible to delete any previously present parent node.


wxXmlNode::SetProperties

void SetProperties(wxXmlProperty* prop)

Sets as first property the given wxXmlProperty object. The caller is responsible to delete any previously present properties attached to this node.


wxXmlNode::SetType

void SetType(wxXmlNodeType type)

Sets the type of this node.


wxXmlNode::operator=

wxXmlNode& operator operator=(const wxXmlNode& node)

See the copy constructor for more info.