WebKDC::XmlElement - Parse and manipulate XML documents and
elements
use WebKDC::XmlElement;
my $root = WebKDC::XmlElement->new ($xml);
my $e = $root->find_child ('foo');
my $content = $e->content_trimmed;
print $root->to_string (1);
A WebKDC::XmlElement object represents an XML element, including
its attributes, textual content, and any nested elements. It therefore can
represent an entire XML document, although XML documents are normally
constructed via the methods provided by WebKDC::XmlDoc. It is used
internally by the WebKDC module to create and parse XML documents when
talking to a WebAuth WebKDC.
- new ([XML])
- Create a new WebKDC::XmlElement. If XML is given, do so by parsing that
XML using XML::Parser. The resulting element will represent the complete
structure of that document, including any nested elements, any attributes,
and any non-element content.
- add_child
(ELEMENT)
- Add a WebKDC::XmlElement object as a child of this element. It will be
appended to the end of the list of all existing children.
- append_content
(CONTENT)
- Append the provided content to the textual content of this element.
- attr (NAME[, VALUE])
- Retrieve or set the value of a specific attribute. Returns undef if that
attribute isn't present for this element.
- attrs ([ATTRS])
- Retrieve or set the attributes for this element (as a reference to an
anonymous hash).
- children
([CHILDREN])
- Retrieve or set the children of this element (as a reference to an
anonymous array of WebKDC::XmlElement objects).
- content
([CONTENT])
- Retrieve or set the textual content of this element as a string, not
including any child elements. Returns undef if the element has no
content.
- content_trimmed
()
- Retrieve the textual content of this element with all leading and trailing
whitespace removed. Returns undef if the element has no content.
- find_child
(NAME)
- Returns the first child (as a WebKDC::XmlElement object) of this element
whose name matches NAME.
- has_attrs
()
- Returns true if this element has attributes, false otherwise.
- has_children
()
- Returns true if this element has children, false otherwise.
- name ([NAME])
- Retrieve or set the name of this element as a string.
- to_string
()
- Convert this XML element (and, recursively, all of its children) to
XML.
Roland Schemers and Russ Allbery <eagle@eyrie.org>
WebKDC(3), WebKDC::XmlDoc(3)
This module is part of WebAuth. The current version is available
from <http://webauth.stanford.edu/>.