NAME

XML::XPath::Helper::Const - Exports some precompiled xpath constants for XML::LibXML.

VERSION

Version 0.04

SYNOPSIS

@nodes = $my_node->findnodes(XPATH_SIMPLE_LIST);

DESCRIPTION

This module provides some precompiled XPath expressions (refer to XML::LibXML::XPathExpression for details about this).

The provided constants are:

XPATH_SIMPLE_LIST

Selects the "simple list nodes" contained in the current node; i.e. the nodes that contain at least one child node, all the child nodes have the same name and no child node has child nodes again.

Example:

my $dom = XML::LibXML->load_xml(string => <<'EOT');
<root>
<findthis>
<entry>a</entry>
<entry>b</entry>
<entry>c</entry>
</findthis>
<ignorethis>
<foo>a</foo>
<bar>b</bar>
</ignorethis>
<ignorethat>
<child>
<childofchild></childofchild>
</child>
</ignorethat>
<simpletag>blah</simpletag>
</root>
EOT
my @nodes = $dom->documentElement->findnodes(XPATH_SIMPLE_LIST);

Array @nodes contains a single node: <findthis>

XPATH_SIMPLE_TAGS

Find all nodes that have no child nodes.

XPATH_NESTED_TAGS

Find all nodes that have at least one child node.

EXPORT

This modules exports nothing by default. You can export the constants you need individually, or use tag :all to export them all.,

SEE ALSO

XML::LibXML, XML::LibXML::XPathExpression, XML::XPath::Helper::String

AUTHOR

Abdul al Hazred, <451 at gmx.eu>

BUGS

Please report any bugs or feature requests to bug-xml-xpath-helper-const at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-XPath-Helper-Const. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc XML::XPath::Helper::Const

You can also look for information at:

ACKNOWLEDGEMENTS

The XPath expression for XPATH_SIMPLE_LIST is taken from here: https://stackoverflow.com/questions/75059177/is-it-possible-to-find-nodes-containing-a-simple-list-using-xpath-1-0/75061420#75061420. Thanks to Michael Kay who posted this solution.

LICENSE AND COPYRIGHT

This software is copyright (c) 2023 by Abdul al Hazred.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.