Text::FakeXML - Creating text with <things>.
Many applications use XML-style data, e.g., for configuration. However, very often this data is not 'real' XML, but just text with some XML-like markups. Therefore is it not necessary to pull in the whole vast XML machinery to create these files. A simple 'fake' module is sufficient.
For example, consider this real-life config file for eye-of-gnome:
<entry name='geometry_collection' mtime='1164190071' type='string'>
This doesn't require anything fancy:
my $cfg = Text::FakeXML->new(version => "1.0");
$cfg->xml_elt("entry", name => "geometry_collection",
mtime => "1164190071", type => "string");
$cfg->xml_elt("stringvalue", "440x350+1063+144" );
Constructor. Takes an optional series of key/value pairs:
The file handle where to write the output to. If not specified, the currently selected file handle is used.
If specified, a leading <?xml version=...?> is emitted.
Indentation for each level of tags. Must be a string (e.g., two spaces " ") or a number that indicates the desired number of spaces. Default is two spaces.
The starting level of indentation. Defaults to zero.
my $o = Text::FakeXML::new version => '1.0';
Emits the opening tag for a new element. First argument is the name of the element. It may be followed by a series of key/value pairs that will be used as attributes for this element.
Closes the current element. First (and only) argument is the name of the element.
Outputs a simple element. First argument is the name of the element, the second argument (if present) is the value. This may be followed by a series of key/value pairs that will be used as attributes for this element.
$o->xml_elt("foo") -> <foo />
$o->xml_elt("foo", "bar") -> <foo>bar</foo>
id => 1) -> <foo id='1'>bar</foo>
id => 1) -> <foo id='1' />
Outputs a comment. Arguments contain the comment text.
Johan Vromans, <jv at cpan.org>
<jv at cpan.org>
Please report any bugs or feature requests to bug-text-fakexml at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Text-FakeXML. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-text-fakexml at rt.cpan.org
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker
Copyright 2008 Johan Vromans, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Text::FakeXML, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.