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

Utility class to create valid XML strings

Methods

add_attribute, add_cdata, add_child, add_data, add_xml, new, set_namespace, to_parent, to_s, to_xml,
Attributes

 [RW]  :parent

The parent XMLElement

Public Class methods
new(tag, attributes={}) src

Construct an XMLElement for the supplied tag and attributes

tag:[String] XML tag
attributes:[Hash = {}] The attribute hash[attribute]=value
Public Instance methods
add_attribute(attrib, value) src

Adds an attribute to this element

attrib:[String] The attribute name
value:[String] The attribute value
return:[Jabber::Protocol::XMLElement] self for chaining #
add_data(data) src

Adds data to this element

data:[String] The data to add
return:[Jabber::Protocol::XMLElement] self for chaining
set_namespace(ns) src

Sets the namespace for this tag

ns:[String] The namespace
return:[Jabber::Protocol::XMLElement] self for chaining
add_cdata(cdata) src

Adds cdata to this element

cdata:[String] The cdata to add
return:[Jabber::Protocol::XMLElement] self for chaining
to_parent() src

Returns the parent element

return:[Jabber::Protocol::XMLElement] The parent XMLElement
add_child(tag, attributes={}) src

Adds a child to this element of the supplied tag

tag:[String] The element tag
attributes:[Hash = {}] The attributes hash[attribute]=value
return:[Jabber::Protocol::XMLElement] newly created child element
add_xml(xml) src

Adds arbitrary XML data to this object

xml:[String] the xml to add
to_xml(format, indent=0) src

Recursively builds the XML string by traversing this element's children.

format:[Boolean] True to pretty-print (format) the output string
indent:[Integer = 0] The indent level (recursively more)
to_s() src

Climbs to the top of this elements parent tree and then returns the to_xml XML string.

return:[String] The XML string of this element (from the topmost parent).