Class: Wx::XmlNode

Inherits:
Object
  • Object
show all
Defined in:
lib/wx/doc/gen/xml_node.rb

Overview

Note:

This class is untracked and should not be derived from nor instances extended!

Represents a node in an XML document.

See XmlDocument. Each node is named and depending on the node type it may also hold content or be given attributes. The two most common node types are Wx::XmlNodeType::XML_ELEMENT_NODE and Wx::XmlNodeType::XML_TEXT_NODE. Wx::XmlNodeType::XML_ELEMENT_NODE represents a pair of XML element tags, whilst Wx::XmlNodeType::XML_TEXT_NODE represents the text value that can belong to the element. A Wx::XmlNodeType::XML_ELEMENT_NODE has a title, and optionally attributes, but does not have any content. A Wx::XmlNodeType::XML_TEXT_NODE does not have a title or attributes but should normally have content. For example: in the XML fragment <title>hi</title> there is an element node with the name title and a single text node child with the text hi as content. A Wx::XmlNodeType::XML_PI_NODE represents a Processing Instruction (PI) node with the name parameter set as the target and the contents parameter set as the instructions. Note that whilst the PI instructions are often in the form of pseudo-attributes, these do not use the node’s attribute member. It is the user’s responsibility to code and decode the PI instruction text. The Wx::XmlNodeType::XML_DOCUMENT_TYPE_NODE is not implemented at this time. Instead, you should get and set the DOCTYPE values using the XmlDocument class. If Setup::USE_UNICODE is 0, all strings are encoded in the encoding given to Wx::XmlDocument::Load (default is UTF-8).

Note:

Once a XmlNode has been added to a XmlDocument it becomes owned by the document and this has two implications. Firstly, the XmlDocument takes responsibility for deleting the node so the user should not delete it; and secondly, a XmlNode must always be created on the heap and never on the stack.

Category: XML

See Also:

  • XmlDocument
  • XmlDoctype
  • XmlAttribute

Requires:

  • USE_XML

Instance Method Summary collapse

Constructor Details

#initialize(type, name, content = (''), lineNo = -1) ⇒ Wx::XmlNode #initialize(node) ⇒ Wx::XmlNode

Returns a new instance of XmlNode.

Overloads:

  • #initialize(type, name, content = (''), lineNo = -1) ⇒ Wx::XmlNode

    A simplified version of the first constructor form, assuming a NULL parent.

    Parameters:

  • #initialize(node) ⇒ Wx::XmlNode

    Copy constructor.

    Note that this does NOT copy siblings and parent pointer, i.e. #get_parent and #get_next will return NULL after using copy ctor and are never unmodified by operator=(). On the other hand, it DOES copy children and attributes.

    Parameters:



131
# File 'lib/wx/doc/gen/xml_node.rb', line 131

def initialize(*args) end

Instance Method Details

#add_attribute(name, value) ⇒ void

This method returns an undefined value.

Appends an attribute with given name and value to the list of attributes for this node.

Parameters:

  • name (String)
  • value (String)


137
# File 'lib/wx/doc/gen/xml_node.rb', line 137

def add_attribute(name, value) end

#add_child(child) ⇒ void

This method returns an undefined value.

Adds node child as the last child of this node.

Once added, the XML tree takes ownership of this object and there is no need to delete it.

Note:

Note that this function works in O(n) time where n is the number of existing children. Consequently, adding large number of child nodes using this method can be expensive, because it has O(n^2) time complexity in number of nodes to be added. Use #insert_child_after to populate XML tree in linear time.

Parameters:

See Also:



152
# File 'lib/wx/doc/gen/xml_node.rb', line 152

def add_child(child) end

#delete_attribute(name) ⇒ Boolean

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

Parameters:

  • name (String)

Returns:

  • (Boolean)


157
# File 'lib/wx/doc/gen/xml_node.rb', line 157

def delete_attribute(name) end

#get_attribute(attrName, defaultVal = ('')) ⇒ String Also known as: attribute

Returns the value of the attribute named attrName if it does exist.

If it does not exist, the defaultVal is returned.

Parameters:

  • attrName (String)
  • defaultVal (String) (defaults to: (''))

Returns:

  • (String)


165
# File 'lib/wx/doc/gen/xml_node.rb', line 165

def get_attribute(attrName, defaultVal=('')) end

#get_childrenWx::XmlNode Also known as: children

Returns the first child of this node.

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

Returns:



172
# File 'lib/wx/doc/gen/xml_node.rb', line 172

def get_children; end

#get_contentWx::String Also known as: content

Returns the content of this node.

Can be an empty string. Be aware that for nodes of type Wx::XmlNodeType::XML_ELEMENT_NODE (the most used node type) the content is an empty string. See #get_node_content for more details.

Returns:

  • (Wx::String)


179
# File 'lib/wx/doc/gen/xml_node.rb', line 179

def get_content; end

#get_depth(grandparent = nil) ⇒ Integer Also known as: depth

Returns the number of nodes which separate 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 Wx::XmlDocument‘s root element node).

Parameters:

Returns:

  • (Integer)


187
# File 'lib/wx/doc/gen/xml_node.rb', line 187

def get_depth(grandparent=nil) end

#get_line_numberInteger Also known as: line_number

Returns line number of the node in the input XML file or -1 if it is unknown.

Returns:

  • (Integer)


200
# File 'lib/wx/doc/gen/xml_node.rb', line 200

def get_line_number; end

#get_nameWx::String Also known as: name

Returns the name of this node.

Can be an empty string (e.g. for nodes of type Wx::XmlNodeType::XML_TEXT_NODE or Wx::XmlNodeType::XML_CDATA_SECTION_NODE).

Returns:

  • (Wx::String)


207
# File 'lib/wx/doc/gen/xml_node.rb', line 207

def get_name; end

#get_nextWx::XmlNode Also known as: next_

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

Returns:



212
# File 'lib/wx/doc/gen/xml_node.rb', line 212

def get_next; end

#get_no_conversionBoolean Also known as: no_conversion

Returns a flag indicating whether encoding conversion is necessary when saving.

The default is false. You can improve saving efficiency considerably by setting this value.

Returns:

  • (Boolean)


195
# File 'lib/wx/doc/gen/xml_node.rb', line 195

def get_no_conversion; end

#get_node_contentString Also known as: node_content

Returns the content of the first child node of type Wx::XmlNodeType::XML_TEXT_NODE or Wx::XmlNodeType::XML_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_ELEMENT_NODE name="tagname", content=""
  |-- wxXML_TEXT_NODE name="", content="tagcontent"

or eventually:

wxXML_ELEMENT_NODE name="tagname", content=""
  |-- wxXML_CDATA_SECTION_NODE name="", content="tagcontent"

An empty string is returned if the node has no children of type Wx::XmlNodeType::XML_TEXT_NODE or Wx::XmlNodeType::XML_CDATA_SECTION_NODE, or if the content of the first child of such types is empty.

Returns:

  • (String)


233
# File 'lib/wx/doc/gen/xml_node.rb', line 233

def get_node_content; end

#get_parentWx::XmlNode Also known as: parent

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

Returns:



238
# File 'lib/wx/doc/gen/xml_node.rb', line 238

def get_parent; end

#get_typeWx::XmlNodeType Also known as: type

Returns the type of this node.

Returns:



243
# File 'lib/wx/doc/gen/xml_node.rb', line 243

def get_type; end

#has_attribute(attrName) ⇒ Boolean Also known as: has_attribute?

Returns true if this node has a attribute named attrName.

Parameters:

  • attrName (String)

Returns:

  • (Boolean)


249
# File 'lib/wx/doc/gen/xml_node.rb', line 249

def has_attribute(attrName) end

#insert_child(child, followingNode) ⇒ Boolean

Inserts the child node immediately before followingNode in the children list.

Once inserted, the XML tree takes ownership of the new child and there is no need to delete it. true if followingNode has been found and the child node has been inserted.

Note:

For historical reasons, followingNode may be NULL. In that case, then child is prepended to the list of children and becomes the first child of this node, i.e. it behaves identically to using the first children (as returned by #get_children) for followingNode).

Parameters:

Returns:

  • (Boolean)

See Also:



267
# File 'lib/wx/doc/gen/xml_node.rb', line 267

def insert_child(child, followingNode) end

#insert_child_after(child, precedingNode) ⇒ Boolean

Inserts the child node immediately after precedingNode in the children list.

Once inserted, the XML tree takes ownership of the new child and there is no need to delete it. true if precedingNode has been found and the child node has been inserted.

Parameters:

  • child (Wx::XmlNode)

    The child to insert.

  • precedingNode (Wx::XmlNode)

    The node to insert child after. As a special case, this can be NULL if this node has no children yet in that case, child will become this node’s only child node.

Returns:

  • (Boolean)

See Also:



278
# File 'lib/wx/doc/gen/xml_node.rb', line 278

def insert_child_after(child, precedingNode) end

#is_whitespace_onlyBoolean Also known as: whitespace_only?

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.

Returns:

  • (Boolean)


284
# File 'lib/wx/doc/gen/xml_node.rb', line 284

def is_whitespace_only; end

#set_content(con) ⇒ void Also known as: content=

This method returns an undefined value.

Sets the content of this node.

Parameters:

  • con (String)


290
# File 'lib/wx/doc/gen/xml_node.rb', line 290

def set_content(con) end

#set_name(name) ⇒ void Also known as: name=

This method returns an undefined value.

Sets the name of this node.

Parameters:

  • name (String)


296
# File 'lib/wx/doc/gen/xml_node.rb', line 296

def set_name(name) end

#set_no_conversion(noconversion) ⇒ void Also known as: no_conversion=

This method returns an undefined value.

Sets a flag to indicate whether encoding conversion is necessary when saving.

The default is false. You can improve saving efficiency considerably by setting this value.

Parameters:

  • noconversion (Boolean)


305
# File 'lib/wx/doc/gen/xml_node.rb', line 305

def set_no_conversion(noconversion) end

#set_type(type) ⇒ void Also known as: type=

This method returns an undefined value.

Sets the type of this node.

Parameters:



311
# File 'lib/wx/doc/gen/xml_node.rb', line 311

def set_type(type) end