【发布时间】:2012-01-29 10:15:21
【问题描述】:
我正在尝试从 .xml 文件中读取一些信息并使用 jQuery Mobile 将其显示在列表视图中。我搜索了各种方法,但我无法做到...有人可以帮我吗?
谢谢
<!DOCTYPE html>
<html>
<head>
<title>XXXXXX</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jqm-docs.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
从标记获取信息的脚本
<script type="text/javascript">
function initialize() {
jQuery.get("markers.xml", {}, function(data) {
jQuery(data).find("marker").each(function() {
var marker = jQuery(this);
var name = marker.attr("name");
$("last").append('<li class="arrow">' + name + '</li>');
});
});
}
</script>
</head>
HTML 正文.. div=id 是否正确?
<body onLoad="initialize()">
<div data-role="page" class="type-home">
<div data-role="header">
<h1>XXX</h1>
</div>
<div data-role="content">
<div class="content-secondary">
<div id="jqm-homeheader">
<h1 id="jqm-logo"><img src="images/logo_final.jpg"/></h1>
</div>
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
<li data-role="list-divider">Menu</li>
<li class="arrow"><a href="inserir.html" data-transition="slide">Inserir</a></li>
<li class="arrow"><a href="find.html" data-transition="slide">Procurar</a></li>
<li class="arrow"><a href="map.html" data-transition="slide">Mapa</a></li>
<li class="arrow"><a href="contact_us.html" data-transition="slide">Termos e Condições</a></li>
<li class="arrow"><a href="contact_us.html" data-transition="slide">Contact Us</a></li>
</ul>
</div>
<div class="content-primary" id="last">
<ul data-role="listview">
<li data-role="list-divider">Ultimos:</li>
</ul>
</div>
</div>
</div>
</body>
</html>
-----------更新------------
XML 代码
<?xml version="1.0" encoding="utf-8"?>
<!--
- Database: 'ond68nda_dataBase'
-->
<database name="ond68nda_dataBase">
<!-- Table markers -->
<table name="markers">
<column name="id">1</column>
<column name="name">asd</column>
<column name="address">dasd</column>
<column name="lat">37.437130</column>
<column name="lng">-122.117012</column>
<column name="type">restaurant</column>
</table>
<table name="markers">
<column name="id">2</column>
<column name="name">asd</column>
<column name="address">dasd</column>
<column name="lat">37.437130</column>
<column name="lng">-122.117012</column>
<column name="type">restaurant</column>
</table>
<table name="markers">
<column name="id">3</column>
<column name="name">dasd</column>
<column name="address">dasdas</column>
<column name="lat">37.440266</column>
<column name="lng">-122.137436</column>
<column name="type">restaurant</column>
</table>
<table name="markers">
<column name="id">4</column>
<column name="name"></column>
<column name="address"></column>
<column name="lat">0.000000</column>
<column name="lng">0.000000</column>
<column name="type"></column>
</table>
【问题讨论】:
-
您能具体说明您面临的问题吗
标签: jquery xml listview mobile jquery-mobile