如何从Perl创建XML? [英] How can I create XML from Perl?

查看:84
本文介绍了如何从Perl创建XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Perl中创建XML.根据我的阅读, XML :: LibXML 非常适合解析和使用来自别的地方.有没有人对XML Writer有任何建议?是否仍然保持 XML :: Writer ?有人喜欢/使用它吗?

I need to create XML in Perl. From what I read, XML::LibXML is great for parsing and using XML that comes from somewhere else. Does anyone have any suggestions for an XML Writer? Is XML::Writer still maintained? Does anyone like/use it?

除了功能完整之外,我还对一种易于使用的语法感兴趣,因此请在答案中描述该语法以及您喜欢该模块的其他原因.

In addition to feature-completeness, I am interested an easy-to-use syntax, so please describe the syntax and any other reasons why you like that module in your answer.

请对每个答案提出一个建议,如果有人已经回答了您的最爱,请对该答案进行投票.希望可以很容易地看到最受欢迎的内容.

Please respond with one suggestion per answer, and if someone has already answered with your favorite, please vote that answer up. Hopefully it will be easy to see what is most popular.

谢谢!

推荐答案

XML :: Writer仍被维护(至少从今年2月开始),它的确是那里最受欢迎的Perl XML编写器之一.

XML::Writer is still maintained (at least, as of February of this year), and it's indeed one of the favorite Perl XML writers out there.

至于描述语法,最好查看模块的文档(链接已在问题中).发挥作用:

As for describing the syntax, one is better to look at the module's documentation (the link is already in the question). To wit:

use XML::Writer;

my $writer = new XML::Writer();  # will write to stdout
$writer->startTag("greeting", 
                  "class" => "simple");
$writer->characters("Hello, world!");
$writer->endTag("greeting");
$writer->end();

# produces <greeting class='simple'>Hello world!</greeting>

这篇关于如何从Perl创建XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆