如何在DIV中显示XML数据 [英] How to display XML Data in DIV

查看:794
本文介绍了如何在DIV中显示XML数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在DIV中显示XML数据。我的xml代码如下:

I want to show XML data in DIV. My xml code is below:

<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don’t forget me this weekend!</body>
</note>

我希望它在div中完全显示,包含所有行间距和xml标签完全如此。

I want it to be displayed exactly as it is in a div, with all line spacing and xml tags exactly as they are.

这可能吗?

推荐答案

所以我想您的问题是您正在尝试将XML代码放入DIV中,并且浏览器会尝试将XML标记解释为HTML标记吗?您可以通过替换所有<来防止这种情况XML代码中的>和HTML特殊字符& gt;和& lt。

So I guess your problem is that you are trying to put the XML code into the DIV, and the browser tries to interprete the XML tags as HTML tags? You can prevent that by replacing all "<" and ">" in the XML code with the HTML special chars &gt; and &lt.

这篇关于如何在DIV中显示XML数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆