在HTML中向XDOC传递XML格式的XDATA数据

将xml数据放入script标签中可以在不转码的情况下放入html中。这样就能简单的向XDOC传递XML格式的XDATA数据。

<!DOCTYPE html>
<html>
  <head> 
    <meta charset="UTF-8">
    <script type="text/javascript" src="http://www.xdocin.com/xdoc.js"></script> 
  </head>  
  <body> 
    <script id="xdata" type="text/xdata"> 
<rss version="2.0">
  <channel>
    <title>新闻国内</title>
    <image>
      <title>新闻国内</title>
      <link>http://news.qq.com</link>
      <url>http://mat1.qq.com/news/rss/logo_news.gif</url>
    </image>
    <description>新闻国内</description>
    <link>http://news.qq.com/china_index.shtml</link>
    <copyright>Copyright 1998 - 2005 TENCENT Inc. All Rights Reserved</copyright>
    <language>zh-cn</language>
    <generator>www.qq.com</generator>
    <item>
      <title>丽水男子发现滑坡迹象第一个报警 劝走4户邻居</title>
      <link>http://news.qq.com/a/20151114/035721.htm</link>
      <author>www.qq.com</author>
      <category/>
      <pubDate>2015-11-14 21:58:00</pubDate>
      <comments/>
      <description>小李发现滑坡迹象后,第一时间拨打了110和119电话报警。浙江在线丽水11月14日讯(浙江在线记者/胡昊编辑/沈正玺)11月13日22点50分许,丽水市莲都区雅溪镇里东村发生山体滑坡。</description>
    </item>
    <item>
      <title>巴黎黑色星期五 防暴恐看看国家为我们做了什么</title>
      <link>http://news.qq.com/a/20151114/034859.htm</link>
      <author>www.qq.com</author>
      <category/>
      <pubDate>2015-11-14 21:23:45</pubDate>
      <comments/>
      <description>今天一早,长安君和大家一样就看到了震惊世界的头条:13日晚,法国巴黎市中心发生多起暴恐分子枪击、爆炸事件,伤亡已超过百人,法国政府已宣布全国进入紧急状态。</description>
    </item>
  </channel>
</rss>
    </script>
    <script type="text/javascript">
	XDoc.run("./rss.xdoc", "pdf", {_xdata:document.getElementById("xdata").innerHTML});
    </script>
  </body> 
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值