06 Nov 2002 19:44:41 UTC
- Distribution: Parse-Any2xml
- Module version: 2.01
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (4 / 0 / 0)
- License: unknown
- Activity24 month
- Download (13.54KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This versionRELIANCE Reliance Technology Consultants, Inc.
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 - Pattern match and extract
_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.
- _set - Source for Match
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().
- _set_foo - set Attribute foo
Allows creation of attribute with the name 'foo'.
- _exp - Perl expression
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 - Fill Element
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">
- _debug-level - Print debugging/verbosity
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.
- Double-quoted Expressions
All values specified in double quotes for
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.
- Mailing List
- Web site
Reliance Technology Consultants, Inc. <http://goreliance.com> (Mike MacHenry <firstname.lastname@example.org>)
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 288:
'=item' outside of any '=over'
- Around line 323:
You forgot a '=back' before '=head1'
Module Install Instructions
To install Parse::Any2xml, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Parse::Any2xml
For more information on module installation, please visit the detailed CPAN module installation guide.