Parse::Any2xml - Parse text into XML
use Parse::Any2xml; $ximple_tree = parse( $xtmpl, $text );
Uses a template to make formatted, poorly formatted, or unformatted text into well-formed XML.
parse: <xtmpl> String -> <ximple_tree> Use the XML template to parse the string and return the resultant XML.
You should code at least one element within the root element. Whether to use elements or attributes is your choice. To code attributes use the _set_foo directive discussed below. Any attribute you code without the _set prefix is passed through by Parse::Any2xml.
All Any2XML directives are prefixed with a _ . Your attributes can start with an underscore, provided they do not clash with the defined directives.
_match is an optional tag. By default "(.*)" is its value. It specifies a regular expression including memory and any inline switches.
Thus <newelement _set="$6" _set_abcd="$1*25"_fill="1"/> is same as <newelement _set="$6" _match="(.*)" _set_abcd="$1*25"_fill="1"/>
Unlike Perl's maximum of 9 memory variables ($1 .. $9), here you have unlimited memory variables, i.e. you can have $15, $20 etc. according to your match expression.
Example: _match="(?is)name:\s*(.*?)\n\s*address:\s*(.*?)\n"
_match="(?is)name:\s*(.*?)\n\s*address:\s*(.*?)\n"
Sets the source that needs to be parsed (or further evaluated) according to the _match directive. This value is usually a matched memory value from a previous higher level match.
Note that its value is a valid Perl expression to be evaluated using eval().
Example: _set="$1.'-'.$2"
_set="$1.'-'.$2"
Allows creation of attribute with the name 'foo'.
Example: _set_amount="$3+$4-$5"
_set_amount="$3+$4-$5"
This sets the contents of an element if and only if _fill is used; it is ignored if _fill is not used. The contents of the element will be the result of this Perl expression.
Fill the current element using _exp if it exists, otherwise _set . Without this Parse::Any2xml will create an empty element. Using _fill destroys data such that an element's child will not be able to match on it.
Example 1: <address _set="$4" _fill="1"> Example 2: <company _set="$2" _set_name="$1" _exp="'Got'.$1.'Hooray'" _fill="1">
Accepts a level number that ranges from 0 to 63, printing lots of information each time. The number is actually a bitwise number, much like chmod takes for permissions, so take any from the following table and add them together for your desired level of debugging.
All values specified in double quotes for _match, _set, and _exp are eval()ed as Perl code. So any legal Perl code is allowed in here. So if you code any literals, you need to code them within single quotes and concatenate with any expressions used. Perl's rules in escaping special characters apply here. If the return value is a null or numeric or character zero, the value returned is null (i.e. ""). If you want to see a space or zero instead, concatenate a space or zero in front of the result.
_match
_set
_exp
eval()
<http://goreliance.com/mailman/listinfo/parse-any2xml-list>
<http://goreliance.com/devel/parse-any2xml>
Reliance Technology Consultants, Inc. <http://goreliance.com> (Mike MacHenry <dskippy@ccs.neu.edu>)
XML::Ximple
2 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
To install Parse::Any2xml, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::Any2xml
CPAN shell
perl -MCPAN -e shell install Parse::Any2xml
For more information on module installation, please visit the detailed CPAN module installation guide.