我想将我的XML文件链接到我的HTML页面 [英] I want to link my XML file to my HTML page

查看:323
本文介绍了我想将我的XML文件链接到我的HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个XML文件,我希望它可以显示在我也创建的HTML页面中。有人可以告诉我怎么做。

 <?xml version =1.0?> 
< Family>
<妈妈>艾莉森< /妈妈>
< age> 44< / age>
< son> Ian< / son>
< age> 8< / age>
< son> Seth< / son>
< / Family>

我想从我的html页面阅读

解决方案

a)简单地链接您的Xml文件 您可以链接到您的Xml文件如果您的Web服务器被配置为允许此功能(通常由于安全原因而禁用),您只需要使用服务器端包含服务器端包含的Html页面即可。 将您的Html页面重命名为.shtml并添加服务器端 include 命令。


$ b

foo.shtml

 < html> 
< head />
< body>
<! - #include file =bar.xml - >
< / body>
< / html>

bar.xml

 <?xml version =1.0?> 
< Family>
<妈妈>艾莉森< /妈妈>
< age> 44< / age>
< son> Ian< / son>
< age> 8< / age>
< son> Seth< / son>
< / Family>

这将显示文本 Alison 44 Ian 8 Seth 在您的浏览器中。






b)将您的Xml文件呈现为Html



如果要将完整的Xml文件呈现为Html页面 wenuxas 对您有正确的答案。






c)将您的Xml文件嵌入到您的Html页面中
$ b Xml文档仅代表最终页面的一部分 Ajax 可能就是您要的内容为。


I have created a XML file I would like for it to be displayed in my HTML page that I also created. Can someone tell me how to do this.

<?xml version="1.0"?>
<Family>
<Mom>Alison</Mom>
<age>44</age>
<son>Ian</son>
<age>8</age>
<son>Seth</son>
</Family>

I would like to read that from my html page

解决方案

a) Simply linking your Xml file

You can link to your Xml file from a Html page by using Server Side Includes.

If your Webserver is configured to allow this feature (this is usually disabled for security reasons) all you need to do is to rename your Html page to .shtml and add the server side include command.

foo.shtml

<html>
    <head/>
    <body>
    <!--#include file="bar.xml" -->
    </body>
</html>

bar.xml

<?xml version="1.0"?>
<Family>
    <Mom>Alison</Mom>
    <age>44</age>
    <son>Ian</son>
    <age>8</age>
    <son>Seth</son>
</Family>

This will show the text Alison 44 Ian 8 Seth in your browser.


b) Rendering your Xml file as Html

If you want to render your complete Xml file as a Html page wenuxas has the correct answer for you.


c) Embedding your Xml file into your Html page

If your Xml document represents only a fragment of your final page Ajax may be what you are looking for.

这篇关于我想将我的XML文件链接到我的HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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