yet another xml generator
- From: "Martin Busik" <martin.busik@xxxxxxxx>
- Date: Tue, 18 Mar 2008 02:38:35 +0100
Hello,
there are some modules aimed to make the xml generation easy - XML::Generator,
XML::Writer and XML:Writer::Simple, for example.
For my needs, these are to "verbose" and there is too much code necessary
to express the structure of the resulting xml. So I wrote a piece of code
which uses a bit more declarative approach. If somebody finds it useful,
I'd put it on CPAN - or submit it to an existing module.
Let's look at this code:
$str = element "outer", content {
element "inner" => content {
attribute id => 1;
element "abc", undef;
opt_element "def", $value;
element "ghi", "bb & cc";
}
}
provided that $value contains "dummy", $str contains the following result:
<outer>
<inner id='1'>
<abc/>
<def>dummy</def>
<ghi>bb & cc</ghi>
</inner>
</outer>
provided that $value is undef or "", $str would contain:
<outer>
<inner id='1'>
<abc/>
<ghi>bb & cc</ghi>
</inner>
</outer>
Another example:
$str = opt_element "abc", content {
opt_element "def", $value
}
provided $value is undef or "", as result, $str would contain "".
If $value would be "zzz", $str would contain:
<abc>
<def>zzz</dev>
</abc>
Any comments?
Cheers,
Martin
.
- Follow-Ups:
- Re: yet another xml generator
- From: mirod
- Re: yet another xml generator
- From: Darin McBride
- Re: yet another xml generator
- Prev by Date: creating perl binary using PAR module , execution error under unix
- Next by Date: Re: creating perl binary using PAR module , execution error under unix
- Previous by thread: creating perl binary using PAR module , execution error under unix
- Next by thread: Re: yet another xml generator
- Index(es):