XML_Element.at
atkey
Group: Selections
Documentation
Gets a child or attribute of an XML element.
Arguments
key: If anInteger, returns the element at positionatin its list of children. If aText, ifkeystarts with"@", returns the attribute with the given name otherwise returns the first child element with the given name.
Examples
Get a nested tag:
XML_Document.parse '<foo><baz>hello</baz></foo>' . root_element . at 0
# => XML_Document.parse "<baz>hello</baz>" . root_element
Get a tag attribute.
root = XML_Document.parse '<foo bar="one">hello</foo>' . root_element
root.at "@bar"
# => "one"