четверг, 8 декабря 2011 г.

xml javascript jquery HTML

<?xml version="1.1" encoding="UTF-8"?>
<store>
<book>
<title>Nosaukums1</title>
<year>1956</year>
<author>Admin1</author>
<text><![CDATA[ teksts ]]></text>
</book>
<book>
<title>Nosaukums2</title>
<year>1956</year>
<author>Admin2</author>
<text><![CDATA[ teksts ]]></text>
</book>
<book>
<title>Nosaukums3</title>
<year>1956</year>
<author>Admin3</author>
<text><![CDATA[ teksts ]]></text>
</book>
<book>
<title>Nosaukums4</title>
<year>1956</year>
<author>Admin4</author>
<text><![CDATA[ teksts ]]></text>
</book>
</store>
--------------------------------------------------------------------
$(document).ready(function() {
$.get("xml.xml", function(data){
$(data).find("book").each(function(){
//document.write( $(this).find("title").text() + "<br>");
});
});
$.get("xml.xml", function(data){
$(data).children("book").each(function(){
//document.write( $(this).children("title").text() + "<br>");
});
});
$.get("xml.xml", function(data){
$(data).children(":first").children("book").each(function() {
document.write( $(this).children("title").text() + "<br>");
});
});

});
-------------------------------------------------------------------
<!DOCtype HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jScript</title>
<link rel="stylesheet" href="stils.css" type="text/css">
<script type="text/javascript" src="../jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body> 
<div id="main">
</div>
</body>
</html>

Комментариев нет:

Отправить комментарий