1、sites.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<sites>
<site id="0">
<title>Think2Loud</title>
<url>http://www.think2loud.com</url>
<desc>
<brief>this is the brief description.</brief>
<long>...and this is the long description. See how long it is :)</long>
</desc>
</site>
<site id="2">
<title>jaredharbour.com</title>
<url>http://www.jaredharbour.com</url>
<desc>
<brief>this is the brief description.</brief>
<long>...and this is the long description. See how long it is :)</long>
</desc>
</site>
<site id="3">
<title>Css Tricks</title>
<url>http://www.css-tricks.com</url>
<desc>
<brief>this is the brief description.</brief>
<long>...and this is the long description. See how long it is :)</long>
</desc>
</site>
</sites>
2、code
$(document).ready(function(){
$.ajax({
type: "GET",
url: "sites.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('site').each(function(){
var id = $(this).attr('id');
var title = $(this).find('title').text();
var url = $(this).find('url').text();
$('<div class="items" id="link_'+id+'"></div>').html('<a href="'+url+'">'+title+'</a>').appendTo('#page-wrap');
$(this).find('desc').each(function(){
var brief = $(this).find('brief').text();
var long = $(this).find('long').text();
$('<div class="brief"></div>').html(brief).appendTo('#link_'+id);
$('<div class="long"></div>').html(long).appendTo('#link_'+id);
});
});
}
});
});
分享到:
相关推荐
Preface Acknowledgements 1 XML for Data 2 XML Protocols 3 Writing XML with Java 4 Converting Flat Files to XML 5 Reading XML 6 SAX 7 The XMLReader Interface 8 SAX ...
**jQuery阅读时间插件Reading Time详解** jQuery Reading Time 是一个实用的JavaScript插件,它能够自动计算并显示文章或文本的预计阅读时间。这个插件适用于博客、新闻网站或者任何包含大量文字内容的网页,可以...
With this book, you’ll learn everything you need to know from the basics of reading and writing XML data to using the DOM, from LINQ and SQL Server integration to SOAP and web services. What you’...
jQuery分析 初心:希望通过对jQuery这个前端经典库的解释,从而更好地掌握掌握原生的JS各种DOM操作,并继续学习一些jQuery中优雅的封装技巧和重构思路
Mini-XML supports reading of UTF-8 and UTF-16 and writing of UTF-8 encoded XML files and strings. Data is stored in a linked-list tree structure, preserving the XML data hierarchy, and arbitrary ...
Reading XML with QXmlStreamReader Reading XML with DOM Reading XML with SAX Writing XML Chapter 17. Providing Online Help Tooltips, Status Tips, and "What's This?" Help Using a Web ...
在这个场景中,"perl program for xml simple reading" 指的是用Perl编写一个程序来解析XML文件,特别是使用`XML::Simple`模块。描述中提到这是个调试版本,意味着代码可能还存在一些问题,需要进一步优化和改进。 ...
**jQuery Filterizr 图片列表筛选插件详解** Filterizr是一款基于jQuery的强大的图像过滤和排序插件,它允许用户在网页上实现优雅的图片列表筛选效果。通过使用这个插件,开发者可以为网站添加交互性,使用户能够...
jquery.i18n.properties.min.js
Describes the lxml package for reading and writing XML files with the Python programming language.
本文件包含了我在linux下学习opencv Reading Geospatial Raster files with GDAL(使用GDAL读取地理空间栅格文件)中的学习笔记,遇到的bug以及最重要,比较难转换的tif文件
This book is aimed at getting you up and running with jQuery quickly and effectively and, hopefully, having some fun along the way. The entire core jQuery API is discussed, and each API method is ...
If you have no working experience with XML, you should read the appendix, "Introduction to XML," before reading the rest of the book. The appendix will familiarize you with basic XML knowledge that ...
5. **jQuery Mobile with Google Map** - 结合了 jQuery Mobile 和 Google Maps API,使得在移动应用中集成地图功能变得更加简单。 6. **Photoswipe** - 这是一个轻量级的图片查看器插件,特别适合于在移动设备上...
Along with these general skills, the authors illustrate several applications that are relevant to data scientists, such as reading and writing spreadsheet documents both locally and via Google Docs, ...
console.error('Error reading XML:', err); return; } // 解析XML为JavaScript对象 xml2js.parseString(data, (err, result) => { if (err) { console.error('Error parsing XML:', err); return; } //...
Console.WriteLine($"Error occurred while reading or writing: {ex.Message}"); } ``` 在这个过程中,理解XPath(XML路径语言)也可以帮助更高效地定位XML节点。XPath是用于在XML文档中查找信息的语言,尽管在C#...
XML and HTML reading and writing, pull and push parser modes. XML and HTML document tree creation, traversal, load, and save. SAX and extended reader interfaces. DTD and schema validation. Encoding ...
std::cerr << "Error reading XML file" ; } xmlFreeTextReader(reader); } int main() { parseXML("your_xml_file.xml"); return 0; } ``` 此代码片段展示了如何逐节点读取XML文档,并打印出元素节点的信息...
在本案例中,我们讨论的是一个基于jQuery实现的城市选择器,其特点是采用浅绿色调,给人一种温和的感觉,因此特别适合集成到大型项目中。 jQuery是一个强大的JavaScript库,它简化了HTML文档遍历、事件处理、动画...