在 HTML 页面中显示 XML 内容 [英] Display XML content in HTML page
本文介绍了在 HTML 页面中显示 XML 内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在同一页面中显示 XML 和其他类型的数据?
<?xml version="1.0" encoding="ISO-8859-1"?><目录><cd><title>Empire Burlesque</title><艺术家>鲍勃·迪伦</艺术家><国家>美国</国家><country>哥伦比亚</country><价格>10.90</价格><年>1985</年></cd></目录>
上述 XML 应按格式显示.另外,我想在我的页面中显示 HTML 表格和其他内容.如何实现这一目标?
- 我确实在 STRING 中获取 XML,而不是通过文件.
- 我不想解析它
- 我想显示(就是这样)
- 如果你说 XSLT(请举例)
- 我正在考虑使用 Jquery 插件(有任何示例吗?)
解决方案
简单的解决方案是在 元素中嵌入,这将保留格式和尖括号.我还用
style="border:none;"
删除了边框,这使得 textarea 不可见.
这是一个示例:http://jsfiddle.net/y9fqf/1/>
How to display XML and other type of data in same page ?
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<country>Columbia</country>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
The above XML should be displayed as it is with formatting. Also , I would like to display HTML tables and other stuff in my page. How to achieve this ?
- I do get XML in STRING not through file.
- I do not want to parse it
- I want to display (that's it)
- If you say about XSLT ( please give example )
- I'm thinking to use Jquery plugin ( any examples?)
解决方案
Simple solution is to embed inside of a <textarea>
element, which will preserve both the formatting and the angle brackets. I have also removed the border with style="border:none;"
which makes the textarea invisible.
Here is a sample: http://jsfiddle.net/y9fqf/1/
这篇关于在 HTML 页面中显示 XML 内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文