如何链接我的XML路径

时间:2014-01-14 21:36:01

标签: jquery html xml

我目前正在jQuery网站上尝试这个例子:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.parseXML demo</title>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p id="someElement"></p>
<p id="anotherElement"></p>
<script>
var xml = "<rss version='2.0'><channel><title>RSS Title</title></channel></rss>",
xmlDoc = $.parseXML( xml ),
$xml = $( xmlDoc ),
$title = $xml.find( "title" );
// Append "RSS Title" to #someElement
$( "#someElement" ).append( $title.text() );
// Change the title to "XML Title"
$title.text( "XML Title" );
// Append "XML Title" to #anotherElement
$( "#anotherElement" ).append( $title.text() );
</script>
</body>
</html>

我有一个.XML文件存储在同一目录Desktop / example中,如上面的HTML文件,我该如何链接它?我试着将这一行改为:

var xml = "myXmlFile.xml",

它不起作用

0 个答案:

没有答案