Class: JEXML::Element
Overview
Wraps an underlying org.w3c.dom.Element (java.sun.com/javase/6/docs/api/org/w3c/dom/Element.html).
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#attribute(name) ⇒ Object
Get the value of the attribute with the specified name.
-
#set_attribute(name, value) ⇒ Object
Get the value of the attribute with the specified name.
Methods inherited from Node
#<<, #add_child_node, #child_elements, #child_nodes, create, #document, #element, #elements, #first_child_element, #first_child_node, #initialize, #name, #node, #nodes, #normalize, #remove_child_nodes, #replace_child_node, #text, #text=, #type_code, #value
Constructor Details
This class inherits a constructor from JEXML::Node
Instance Method Details
#attribute(name) ⇒ Object
Get the value of the attribute with the specified name.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jexml/element.rb', line 5 def attribute(name) value = java_node.getAttribute(name.to_s) # For some reason, the Java SDK returns a blank string if an attribute is not found. # Let's map that back to the more meaningful nil value. if not value.blank? value else nil end end |
#set_attribute(name, value) ⇒ Object
Get the value of the attribute with the specified name.
17 18 19 |
# File 'lib/jexml/element.rb', line 17 def set_attribute(name, value) java_node.setAttribute(name.to_s, value) end |