Catmandu-XML
view release on metacpan or search on metacpan
lib/Catmandu/Fix/xml_read.pm view on Meta::CPAN
my $var = $_[0];
return "my \$stream = XML::LibXML::Reader->new( string => ${var} );".
"${var} = ${xpath} ? [ ${reader}->readDocument(\$stream, ${xpath}) ] " .
": ${reader}->readDocument(\$stream);";
});
});
}
1;
__END__
=head1 NAME
Catmandu::Fix::xml_read - parse XML to MicroXML
=head1 SYNOPSIS
# parse XML string given in field 'xml'
xml_read(xml)
xml_read(xml, simple: 1)
xml_read(xml, attributes: 0)
=head1 DESCRIPTION
This L<Catmandu::Fix> parses XML strings into MicroXML or simple XML with
L<XML::Struct>.
=head1 CONFIGURATION
Parsing can be configured with the following options of L<XML::Struct::Reader>:
=over
=item attributes
Include XML attributes (enabled by default)
=item ns
Define processing of XML namespaces (C<keep> by default)
=item whitespace
Include ignorable whitespace as text elements (disabled by default)
=item simple
Convert to simple key-value structure, as known from L<XML::Simple>
=item root
Keep (and possibly rename) root element when converting to C<simple> form
=item depth
Only transform to a given depth with option C<simple>
=item path
Parse only given elements (and all of its child elements) and return as array.
For instance C<< path => "p" >> in an XHTML document would return a list of
parsed paragraphs (C<< <p>...</p> >>). This option overrides option C<root>.
=item content
Name of text content when converting to C<simple> form
=back
=head1 SEE ALSO
L<Catmandu::Fix::xml_write>,
L<Catmandu::Fix::xml_simple>
L<Catmandu::Fix::xml_transform>
=cut
( run in 2.327 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )