XML-Parser-Wrapper
view release on metacpan or search on metacpan
NOTE: This does not work for the SAX parser interface.
"get_doctype()"
Returns information about the doctype declaration. E.g., for the
declaration
<!DOCTYPE greeting SYSTEM "hello.dtd">
The return value is
{
'pubid' => undef,
'sysid' => 'hello.dtd',
'name' => 'greeting',
'internal' => ''
}
NOTE: This does not work for the SAX parser interface.
"name()"
Returns the name of the element represented by this object.
Aliases: tag(), getName(), getTag()
"is_text()"
Returns a true value if this element is a text element, false otherwise.
Aliases: isText()
"text()"
If this element is a text element, the text is returned. Otherwise,
return the text from the first child text element, or undef if there is
not one.
Aliases: content(), getText(), getContent()
"html()"
Like text(), except HTML-escape the text (escape &, <, >, and ") before
returning it.
Aliases: content_html(), getContentHtml()
"xml()"
Like text(), except XML-escape the text (escape &, <, >, and ") before
returning it.
Aliases: content_xml(), getContentXml()
"to_xml(\%options)"
Converts the node back to XML. The ordering of attributes may not be the
same as in the original XML, and CDATA sections may become plain text
elements, or vice versa. This assumes the data is encoded in utf-8.
Valid options
pretty
If pretty is a true value, then whitespace is added to the output to
make it more human-readable.
cdata
If cdata is defined, any text nodes with length greater than cdata are
output as a CDATA section, unless it contains "]]>", in which case the
text is XML escaped.
Aliases: toXml()
decl
If a true value, output an XML declaration before outputing the
converted document, i.e.,
<?xml version="1.0" encoding="UTF-8"?>
"attributes()", "attributes($name1, $name2, ...)"
If no arguments are given, returns a hash of attributes for this
element. If arguments are present, an array of corresponding attribute
values is returned. Returns an array in array context and an array
reference if called in scalar context.
E.g., for
<field name="foo" id="42">bar</field>
use this to get the attributes:
my ($name, $id) = $element->attributes('name', 'id');
Aliases: attrs(), getAttributes(), getAttrs()
"attribute($name)"
Similar to attributes(), but only returns one value.
Aliases: attr(), getAttribute(), getAttr()
"elements()", "elements($element_name)"
Returns an array of child elements. If $element_name is passed, a list
of child elements with that name is returned.
Aliases: getElements(), kids(), getKids(), children(), getChildren()
"first_element()", "first_element($element_name)"
Returns the first child element of this element. If $element_name is
passed, returns the first child element with that name is returned.
Aliases: getFirstElement(), kid(), first_kid()
"first_element_if($element_name)"
Like first_element(), except if there is no corresponding child, return
an object that will work instead of undef. This allows for reliable
chaining, e.g.
my $class = $root->kid_if('field')->kid_if('field')->kid_if('element')
->kid_if('field')->attribute('class');
Aliases: getFirstElementIf(), kidIf(), first_kid_if()
"new_doc($root_tag_name, \%attr)"
Create a new XML document.
"new_element($tag_name, \%attr, $text_val)"
Create a new XML element object. If $text_val is defined, a child text
node will be created.
( run in 0.633 second using v1.01-cache-2.11-cpan-39bf76dae61 )