WebKDC::XmlDoc(3pm) | User Contributed Perl Documentation | WebKDC::XmlDoc(3pm) |
WebKDC::XmlDoc - Manipulate a document of WebKDC::XmlElement objects
use WebKDC::XmlDoc; my $doc = WebKDC::XmlDoc->new; $doc->start ('root'); $doc->start ('child', { key => 'value' }, 'some content'); $doc->add ('subchild, 'more content'); print $doc->current->name, "\n"; $doc->end; $doc->end; print $doc->root->name, "\n";
A WebKDC::XmlDoc represents an XML document as a tree of WebKDC::XmlElement objects. It is used internally by the WebKDC module to create and parse XML documents when talking to a WebAuth WebKDC.
A (non-empty) document has a root element and a stack of open elements. It is assembled by starting an element (with start(), possibly including attributes and content), manipulating that element if necessary, and then ending the element, done recursively. Once an element has been ended, there is no way using this interface to further change it, although it can be retrieved by getting the root of the tree with root() and then walking the tree. add() is an optimization that combines start() and end() and is more efficient if an element has no child elements.
Most manipulation of this document is done via the WebKDC::XmlElement methods, which allow parsing an XML document into this format, finding children of a particular element, and converting a document to its XML representation. This module only defines the top-level structure and the methods that have to be called on the document as a whole rather than on an individual element.
If the document is empty, the new element becomes the root.
my $xml = $doc->root->to_string;
(which uses the to_string() method of WebKDC::XmlElement).
If the document is empty, the new element becomes the root.
Roland Schemers and Russ Allbery <eagle@eyrie.org>
WebKDC(3), WebKDC::XmlElement(3)
This module is part of WebAuth. The current version is available from <http://webauth.stanford.edu/>.
2019-01-05 | perl v5.28.1 |