【问题标题】:How can I convert XML to HTML?如何将 XML 转换为 HTML?
【发布时间】:2013-09-11 12:14:39
【问题描述】:

我尝试从 Atlassian Confluence API 获取 HTML 页面,但它返回了这样的上下文。如何将这些转换为标准 HTML 标签?

<p style="text-align: center;">&nbsp;</p>
    <p><span style="color: rgb(153,153,153);"><br /></span></p>
    <h2><ac:image><ri:attachment ri:filename="welcome.png" /></ac:image><br />&nbsp; <span style="color: rgb(128,128,128);">With Confluence it is easy to create, edit and share content with your team. Choose a topic below to start learning how.</span></h2>
    <h2><span style="color: rgb(0,0,128);"><br /></span></h2>
    <ol>
        <li><span style="color: rgb(0,0,128);"><ac:link><ri:page ri:content-title="What is Confluence? (step 1 of 9)" /><ac:link-body>What is Confluence?<br /><br /></ac:link-body></ac:link></span></li>
        <li><span style="color: rgb(0,0,128);"><ac:link><ri:page ri:content-title="A quick look at the editor (step 2 of 9)" /><ac:plain-text-link-body><![CDATA[A quick look at the editor]]></ac:plain-text-link-body></ac:link><br />&nbsp;</span></li>
        <li><span style="color: rgb(0,0,128);"><ac:link><ri:page ri:content-title="Let's edit this page (step 3 of 9)" /><ac:plain-text-link-body><![CDATA[Let's edit this page]]></ac:plain-text-link-body></ac:link><br /><br /></span></li>
        <li><span style="color: rgb(0,0,128);"><ac:link><ri:page ri:content-title="Prettify the page with an image (step 4 of 9)" /><ac:link-body>Prettify the page with an image<br /><br /></ac:link-body></ac:link></span></li>
        <li><span style="color: rgb(0,0,128);"><ac:link><ri:page ri:content-title="Get serious with a table (step 5 of 9)" /><ac:link-body>Get serious with a table<br /></ac:link-body></ac:link></span><span style="color: rgb(0,0,128);">&nbsp;</span></li>
        <li><span style="color: rgb(0,0,128);"><ac:link><ri:page ri:content-title="Lay out your page (step 6 of 9)" /><ac:plain-text-link-body><![CDATA[Lay out your page]]></ac:plain-text-link-body></ac:link>&nbsp;<br /><br /></span></li>
        <li><ac:link><ri:page ri:content-title="Learn the wonders of autoconvert (step 7 of 9)" /><ac:plain-text-link-body><![CDATA[Learn the wonders of autoconvert]]></ac:plain-text-link-body></ac:link>&nbsp;<br /><br /></li>
        <li><ac:link><ri:page ri:content-title="Tell people what you think in a comment (step 8 of 9)" /><ac:plain-text-link-body><![CDATA[Tell people what you think in a comment]]></ac:plain-text-link-body></ac:link>&nbsp;<br /><br /></li>
        <li><ac:link><ri:page ri:content-title="Share your page with a team member (step 9 of 9)" /><ac:plain-text-link-body><![CDATA[Share your page with a team member]]></ac:plain-text-link-body></ac:link><br /><br /></li>
        <li><a href="http://directory.apache.org">Apache Directory</a></li>
    </ol>
    <p><span style="color: rgb(128,128,128);"><br /></span></p>
    <p><span style="color: rgb(128,128,128);"><br /></span></p>
    <p><span style="color: rgb(128,128,128);"><br /></span></p><p style="text-align: right;">&nbsp; &nbsp; &nbsp;&nbsp;</p>     

【问题讨论】:

  • p , h2 , ol - 已经是“标准 html 标签”;其他所有内容都被浏览器忽略
  • 我知道 p , h2 , ol 是html标签。但是样式表不适用于这些标签。
  • 什么意思?对我来说工作正常:jsfiddle.net/cherniv/KM6y8
  • 不知道为什么你被否决了......这是一个有效的问题,询问如何将内容从 Confluence 的内部存储格式转换为纯 HTML。也许您没有以不熟悉 Confluence 的人能够理解的方式提出问题?

标签: html xml tags confluence-rest-api


【解决方案1】:

&lt;ac:image&gt; &lt;ri:attachment../&gt; 等是 confluence xhtml 宏,将由 confluence 本身在页面输出中呈现。您必须调用 confluence api 的渲染方法才能将其转换为转换后的 html。

Confluence 在 confluence remote SOAP API -> 页面 -> 管理中为您提供了一个功能:

String renderContent(String token, String spaceKey, String pageId, String content)

【讨论】:

    【解决方案2】:

    有一个用于将 Confluence 页面导出为 HTML 的工具。它被称为 Scroll HTML Exporter。

    https://marketplace.atlassian.com/plugins/com.k15t.scroll.scroll-html/server/overview

    【讨论】:

      猜你喜欢
      • 2012-05-15
      • 1970-01-01
      • 2012-02-06
      • 2013-02-17
      • 2016-02-20
      • 2011-04-12
      • 2019-12-06
      • 1970-01-01
      相关资源
      最近更新 更多