XML / XSLT 中的 HTML 标记
生成 XML 的脚本的一部分,该 XML 由 XSLT 摄取并输出到 HTML 网页。
use XML::Writer ;
$writer->emptyTag('Row' , 'text' => $text ) ;
效果很好,但现在我想在其中放置一些 HTML 标记...而不是:
$text = "Line of text." ;
我需要:
$text = qq |<span class="blah">Line of text.</span>| ;
尝试在字符串中更改
<
为
<
和
>
to
>
但不起作用...
(更新:回复此处的评论...当我说它“不起作用”时,具体来说,尝试传递 HTML 标记是不成功的,因为标记被显示而不是被处理。换句话说,标签没有被应用,它们只是作为一部分显示。 。
AC)谢谢 全部。我正在学习...
Part of a script that generates XML that is ingested by XSLT and spit out to an HTML web page.
use XML::Writer ;
$writer->emptyTag('Row' , 'text' => $text ) ;
Works great, but now I want to put some HTML markup in there... Instead of:
$text = "Line of text." ;
I need:
$text = qq |<span class="blah">Line of text.</span>| ;
Tried changing
<
to
<
and
>
to
>
in the string but didn't work...
(UPDATE: Responding to a comment here... When I said it "didn't work", specifically, the attempt to pass through HTML markup was unsuccessful, because the markup was displayed instead of being processed. In other words, the tags weren't applied, they just showed up as part of the text. AC)
Thanks all. I'm learning...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
emptyTag
调用按预期工作,但看起来 XML::Writer 不会尝试为您提供智能,并确定您传递的数据是否会导致格式错误的 XML。来自 https://metacpan.org/pod/XML::Writer 的文档
: span class="blah">文本行。 因此,您将执行如下操作:
The
emptyTag
call is working as expected, but it looks like XML::Writer is not going to try and be smart for you and figure out if you are passing data that results in badly-formed XML.From the docs at https://metacpan.org/pod/XML::Writer
So, to get the XML
<span class="blah">Line of text.</span>
as a result, you would do something like this: