Class Jabber::Protocol::ParsedXMLElement
In: lib/jabber4r/protocol.rb
Parent: Object

This class is constructed from XML data elements that are received from the Jabber service.

Methods

Classes and Modules

Class Jabber::Protocol::ParsedXMLElement::NilParsedXMLElement

Attributes

element_children  [R]  A hash of ParsedXMLElement children
element_data  [R]  The data <tag>data</tag> for a tag
element_parent  [R]  The parent ParsedXMLElement
element_tag  [R]  The <tag> as String

Public Class methods

Construct an instance for the given tag

tag:[String] The tag
parent:[Jabber::Protocol::ParsedXMLElement = nil] The parent element

Public Instance methods

Calls the parent‘s element_children (hash) index off of this elements tag and gets the supplied index. In this sense it gets its sibling based on offset.

number:[Integer] The number of the sibling to get
return:[Jabber::Protocol::ParsedXMLElement] The sibling element

Add the attribute to the element

  <tag name="value">data</tag>
name:[String] The attribute name
value:[String] The attribute value
return:[Jabber::Protocol::ParsedXMLElement] self for chaining

Factory to build a child element from this element with the given tag

tag:[String] The tag name
return:[Jabber::Protocol::ParsedXMLElement] The newly created child element

Appends data to the element

data:[String] The data to append
return:[Jabber::Protocol::ParsedXMLElement] self for chaining

When an xml is received from the Jabber service and a ParsedXMLElement is created, it is propogated to all filters and listeners. Any one of those can consume the element to prevent its propogation to other filters or listeners. This method marks the element as consumed.

Returns the count of siblings with this element‘s tag

return:[Integer] The number of sibling elements

Checks if the element is consumed

return:[Boolean] True if the element is consumed

Overrides to allow for directly accessing child elements and attributes. If prefaced by attr_ it looks for an attribute that matches or checks for a child with a tag that matches the method name. If no match occurs, it returns a NilParsedXMLElement (singleton) instance.

Example:<alpha number="1"><beta number="2">Beta Data</beta></alpha>
 element.element_tag #=> alpha
 element.attr_number #=> 1
 element.beta.element_data #=> Beta Data

see _count

Returns the valid XML as a string

return:[String] XML string

[Validate]