XML-PugiXML

 view release on metacpan or  search on metacpan

lib/XML/PugiXML.pm  view on Meta::CPAN


=head3 Attributes

=over 4

=item attr($name)

Get attribute by name.

=item attrs()

Return list of all attributes.

=item set_attr($name, $value)

Set attribute value (creates if doesn't exist). Returns the attribute.

=item append_attr($name), prepend_attr($name)

Add attribute at end or beginning.

=item ensure_attr($name)

Get the attribute of this name, creating it if absent. Returns the attribute.
Unlike C<append_attr> it never duplicates an existing attribute. (Uses the
native pugixml 1.16 C<ensure_attribute>; emulated on older libraries.)

=item remove_attr($name)

Remove an attribute by name. Returns true on success.

=back

=head3 Modification

=over 4

=item append_child($name), prepend_child($name)

Add child element at end or beginning.

=item ensure_child($name)

Get the first child of this name (as C<child> does), appending a new element
with that name if none exists. Returns the child; unlike C<append_child> it
never duplicates an existing one. (Native pugixml 1.16 C<ensure_child>;
emulated on older libraries.)

=item insert_child_before($name, $ref_node), insert_child_after($name, $ref_node)

Insert child element before or after a reference node.

=item append_copy($source), prepend_copy($source)

Clone and append/prepend a node (deep copy).

=item insert_copy_before($source, $ref), insert_copy_after($source, $ref)

Clone and insert node before/after reference.

=item append_cdata($content)

Add a CDATA section with the given content.

=item append_comment($content)

Add a comment node with the given content.

=item append_pi($target, $data?)

Add a processing instruction (e.g., C<< <?target data?> >>).

=item remove_child($node)

Remove a child node. Returns true on success.

=item set_name($name), set_value($value), set_text($text)

Modify node properties.

=back

=head3 XPath

=over 4

=item select_node($xpath)

Execute XPath relative to this node, return single result (Node or Attr).

=item select_nodes($xpath)

Execute XPath relative to this node, return list of results (Node and/or Attr).

=back

=head2 XML::PugiXML::Attr

=over 4

=item name(), value()

Get attribute name and value.

=item as_int(), as_uint()

Get value as 32-bit signed/unsigned integer.

=item as_llong(), as_ullong()

Get value as 64-bit signed/unsigned integer.
On 32-bit Perl (IVSIZE < 8), returns a string to avoid truncation.

=item as_double()

Get value as floating-point number.

=item as_bool()

Get value as boolean: true when the first character is in the set C<1tTyY>
(so "1", "true", "yes" are true; "on", "0", "off", "no", "" are false).



( run in 0.976 second using v1.01-cache-2.11-cpan-6aa56a78535 )