【问题标题】:Titanium How to load XML in a webview?Titanium 如何在 webview 中加载 XML?
【发布时间】:2014-07-10 12:58:18
【问题描述】:

我在 iOS/Android 的 Titanium 中编程,我需要在 webview 中加载 XML。 我需要直接在 webview 中加载 XML,而不是从 XML 文件中加载。

所以,我需要使用 webview.setHtml(...) 而不是 webview.url(...)。它可以工作,webview 显示内容,但 setHtml() 方法无法正确加载 XSL 样式文件。

我尝试使用 url() 方法,它可以正常工作并且 XSL 样式文件可以正确加载。但对我来说不是很好的解决方案,因为我需要直接做,没有 XML 文件。

例如,如果我这样做,它可以与 XSL 一起使用:

webview.url='test.xml';

但是这个,显示的是没有 XSL 样式的 XML 内容:

webview.setHtml('<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheethref
="test.xsl" type="text/xsl"?><result><entry><form><orth>ahardi</orth><sf
_set><sf sort="ahardi">.........');

为什么会这样?

提前致谢!

【问题讨论】:

  • 发布一些代码,显示您正在尝试做什么。
  • 好的,我添加一个我想要做的例子。

标签: xml webview titanium


【解决方案1】:

如果第一个例子有效:

webview.url='test.xml';

您可以将生成的 XML 信息写入文件,然后再次使用 webview.url。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多