jquery XML, i need .html() not .text() but not working?
Posted
by Xtian
on Stack Overflow
See other posts from Stack Overflow
or by Xtian
Published on 2010-06-11T20:00:47Z
Indexed on
2010/06/11
20:13 UTC
Read the original article
Hit count: 149
I need var long to be exported as html and not text. I know I have .text() but when I use .html() it will not work. Also if I take the .text() out when declaring the variable and it will not work in IE?
The reason for this is, in the XML certain words will have html tags like or and I need those to be recognized. I thought I solved it when I took out .text() but then i looked at IE and I got nothing.
$(document).ready(function(){
$.ajax({
type: "GET",
url: "xml/sites.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('site').each(function(){
var id = $(this).attr('id');
var title = $(this).find('title').text();
var class =$(this).find('class').text();
$('<div class="'+class+'" id="link_'+id+'"></div>').html('<h2>'+title+'</h2>').appendTo('#page-wrap');
$(this).find('desc').each(function(){
var long = $(this).find('long');
var url = $(this).find('url').text();
$('<div class="long"></div>').html(long).appendTo('#link_'+id);
$('<a href="http://'+url+'"</a>').html(url).appendTo('#link_'+id);
});
});
}
});
});// JavaScript Document
© Stack Overflow or respective owner