[英]XML parse to HTML with jQuery
I have some little problem with my scripts. 我的脚本有一些小问题。 I want to parse xml file with some data elements to my html file.
我想将带有某些数据元素的xml文件解析到我的html文件中。 So I try to use jQuery but it doesn't work.
所以我尝试使用jQuery,但是它不起作用。 Can you help me?
你能帮助我吗?
This is my xlm file: 这是我的xlm文件:
<?xml version="2.0"?>
<choices xml:lang="PL">
<complete>Wskazówka</complete>
<temperature>300 stopni celcjusza</temperature>
</choices>
This is my jQuery code: 这是我的jQuery代码:
$(document).ready(function () {
$.get('../data/content_data.xml', function(data) {
var complete = $(data).find('complete').text();
var temperature = $(data).find('temperature').text();
$('div.menu_circle').text(complete + "|" + temperature);
});
});
I haven't tried this myself, but maybe it helps: 我自己还没有尝试过,但是也许有帮助:
http://www.switchonthecode.com/tutorials/xml-parsing-with-jquery http://www.switchonthecode.com/tutorials/xml-parsing-with-jquery
The issue is how try to output your variables. 问题是如何尝试输出变量。 Try to append your variables to your element.
尝试将变量附加到元素。
$(complete + "|" + temperature).appendTo('div.menu_circle');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.