XML 到字符串的速度
我的 XML 文件包含带有格式化 HTML 的节点。 我正在尝试将 html 内容打印到页面上,但速度正在剥离 HTML 标签。
如何使用速度打印存储在 XML 文件中的 html 内容?
XML 文件
<?xml version="1.0" encoding="utf-8"?>
<system-data-structure>
<heading>This is a Title</heading>
<main>
<content>
<h1>this is formatted html</h1>
<p>content I want <b>to</b> <em>show</em> on my page
</p>
</content>
</main>
</system-data-structure>
速度代码
#set ($html = $contentRoot.getChild('main').getChild('content'))
<h1>$contentRoot.getChild('heading').value</h1>
<div>$html.value</div>
注意:这是我第一次使用速度引擎
I have XML files that have nodes with formatted HTML.
I am trying to print out the html contents to the page but velocity is stripping out the HTML tags.
How do you I print html content stored in an XML file using velocity?
XML File
<?xml version="1.0" encoding="utf-8"?>
<system-data-structure>
<heading>This is a Title</heading>
<main>
<content>
<h1>this is formatted html</h1>
<p>content I want <b>to</b> <em>show</em> on my page
</p>
</content>
</main>
</system-data-structure>
Velocity Code
#set ($html = $contentRoot.getChild('main').getChild('content'))
<h1>$contentRoot.getChild('heading').value</h1>
<div>$html.value</div>
note: this is my first time ever using the velocity engine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
速度不会剥夺任何东西。如果您配置了正确的事件处理程序,您可以拥有 Velocity escape html 输出(我认为您不想要)。但 Velocity 不支持剥离任何内容。
你实际上得到了什么输出?您是否使用为您配置 Velocity 的框架或 CMS?也许是“剥离 html 标签”的其他东西。
Velocity doesn't strip anything out. If you have the right event handlers configured you could have Velocity escape html output (which i don't think you want). But there is no support in Velocity for stripping anything out.
What output are you actually getting? Are you using a framework or CMS that is configuring Velocity for you? Maybe it is something else that is "stripping out the html tags".