日期:2014-05-17  浏览次数:20715 次

在html中原样显示xml文件(firefox)
本帖最后由 wimphy 于 2013-05-08 10:50:24 编辑
html文件(firefox
<HTML>
  <HEAD>
    <meta charset="utf-8" />
    <TITLE>TITLE</TITLE>
  </HEAD>
  <BODY>BODY
  <FRAME SRC = "1.XML"></FRAME>
  </BODY>
</HTML>


xml文件
<?xml version="1.0"?>
<A>A</A>


显示结果
BODY 

期待结果
BODY 
<?xml version="1.0"?>
<A>A</A>

------解决方案--------------------


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="Scripts/jquery-1.9.1.min.js"></script>
    <style type="text/css">

        #placeHolder {
            white-space:pre;
            width:400px;
            height:300px;
            overflow:scroll;
            outline:1px solid #ccc;
        }

    </style>
</head>
<body>

  <div id="placeHolder"></div>
    <script type="text/javascript">

        $(function () {
            
            $.ajax({
                type: "GET",
                url: "test.xml",
                dataType: "text"                
            }).done(function (msg) {
                $("#placeHolder").text(msg);
            });

        });

    </script>
   
</body>
</html>