wxxmlnoderepresents 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 wxxmldocument::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:
see also members
wxxmlnode::wxxmlnode
wxxmlnode::wxxmlnodewxxmlnode(wxxmlnode* parent, wxxmlnodetype type, const wxstring& name, const wxstring& content = wxemptystring, wxxmlproperty* props = null, wxxmlnode* next = null) parameters parent
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::addchildvoid 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::addpropertyvoid 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::deletepropertybool deleteproperty(const wxstring& name) removes the first properties which has the given name from the list of properties for this node.
wxxmlnode::getchildrenwxxmlnode* 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::getcontentwxstring getcontent() const returns the content of this node. can be an empty string. be aware that for nodes of type wxxml_element_node (the most used node type) the content is an empty string. see getnodecontent() for more details.
wxxmlnode::getdepthint getdepth(wxxmlnode* grandparent = null) const returns the number of nodes which separe this node from grandparent. this function searches only the parents of this node until it finds grandparent or the null node (which is the parent of non-linked nodes or the parent of a wxxmldocument's root node).
wxxmlnode::getnodecontentwxstring getnodecontent() const returns the content of the first child node of type wxxml_text_node or wxxml_cdata_section_node. this function is very useful since the xml snippet "<tagname>tagcontent</tagname>" is represented by expat with the following tag tree:
wxxml_entity_node name="tagname", content="" |-- wxxml_text_node name="", content="tagcontent"or eventually:
wxxml_entity_node name="tagname", content="" |-- wxxml_cdata_section_node name="", content="tagcontent"an empty string is returned if the node has no children of type wxxml_text_node or wxxml_cdata_section_node, or if the content of the first child of such types is empty.
wxxmlnode::getnamewxstring 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::getnextwxxmlnode* getnext() const returns a pointer to the sibling of this node or null if there are no siblings.
wxxmlnode::getparentwxxmlnode* getparent() const returns a pointer to the parent of this node or null if this node has no parent.
wxxmlnode::getpropvalbool getpropval(const wxstring& propname, wxstring* value) const returns true if a property named propname could be found. the value of that property is saved in value (which must not be null). 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::getpropertieswxxmlproperty * getproperties() const return a pointer to the first property of this node.
wxxmlnode::gettypewxxmlnodetype gettype() const returns the type of this node.
wxxmlnode::haspropbool hasprop(const wxstring& propname) const returns true if this node has a property named propname.
wxxmlnode::insertchildbool insertchild(wxxmlnode* child, wxxmlnode* before_node) inserts the child node after before_node in the children list. if before_node is null, then child is prepended to the list of children and becomes the first child of this node. returns true if before_node has been found and the child node has been inserted.
wxxmlnode::iswhitespaceonlybool iswhitespaceonly() const returns true if the content of this node is a string containing only whitespaces (spaces, tabs, new lines, etc). note that this function is locale-independent since the parsing of xml documents must always produce the exact same tree regardless of the locale it runs under.
wxxmlnode::removechildbool 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. note that the caller is reponsible for deleting the removed node in order to avoid memory leaks.
wxxmlnode::setchildrenvoid setchildren(wxxmlnode* child) sets as first child the given node. the caller is responsible to delete any previously present children node.
wxxmlnode::setcontentvoid setcontent(const wxstring& con) sets the content of this node.
wxxmlnode::setnamevoid setname(const wxstring& name) sets the name of this node.
wxxmlnode::setnextvoid setnext(wxxmlnode* next) sets as sibling the given node. the caller is responsible to delete any previously present sibling node.
wxxmlnode::setparentvoid setparent(wxxmlnode* parent) sets as parent the given node. the caller is responsible to delete any previously present parent node.
wxxmlnode::setpropertiesvoid 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::settypevoid settype(wxxmlnodetype type) sets the type of this node.
wxxmlnode::operator=wxxmlnode& operator=(const wxxmlnode& node) see the copy constructor for more info.
|