如何在 Perl 中将 XML 转换为字符串
我需要发送 XML 文件作为电子邮件正文。我想将 XML 转换为简单的字符串,将其放入正文中,然后发送电子邮件。我记得我之前在 C# 中通过将文件作为 PlainText 加载到 RichTextBox 中来做到这一点。
my $xmlfilename;
my $myxml;
# XML TO STRING?
my $email = Email::Simple->create(
header => [
To => '"AB <[email protected]"',
From => '"CD" <[email protected]>',
Subject => "TEST",
],
body => $myxml,
);
sendmail($email);
有什么想法吗?
I need to send an XML file as the body of an email. I want to convert the XML to a simple string, put it into the body and then send the email. I remember I did that before in C# by loading the file as PlainText into a RichTextBox.
my $xmlfilename;
my $myxml;
# XML TO STRING?
my $email = Email::Simple->create(
header => [
To => '"AB <[email protected]"',
From => '"CD" <[email protected]>',
Subject => "TEST",
],
body => $myxml,
);
sendmail($email);
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果从文件中读取 XML 数据,那么它将是一个“简单字符串”。我不确定这是什么混乱。
If you read the XML data from the file, then it will be a "simple string". I'm not sure what the confusion is.
或者如果你愿意你可以解析 xml
与 http://metacpan.org/pod/XML::Parser 模块
or if you want you can parse xml
with http://metacpan.org/pod/XML::Parser module