xml appending issue
Posted
by 3gwebtrain
on Stack Overflow
See other posts from Stack Overflow
or by 3gwebtrain
Published on 2010-05-30T06:28:56Z
Indexed on
2010/05/30
6:32 UTC
Read the original article
Hit count: 378
appendchild
Any one help me?
i have the xml with 2 steps. example :
Type of Company: Architects may be self-employed. Workspace – Indoors/outdoors: Architects work both. Environment Travel: Architects often visit construction sites to review the progress of projects. People: They work a lot with other professionals involved in the construction project including engineers, contractors, surveyors and landscape architects. Casual: They usually work in a casual and comfortable environment. Hours: The hours are varied based on the project they are working on. Physically demanding: They stand on their feet. Tools: Computers - Architects Assist clients in obtaining construction bids Observe, inspect and monitor building work
in my funcation i am using "list.each" to append to ul+index. it works fine. And my problem is while i append the "list.each", the "sublistgroup" should not append to "list.each", insted the "sublistgroup" need to make "ul" and in the ul i need the "sublist" became childrens..
my code is here...
i konw that, i am doing some wrong way.. pls any one correct it and let me know..
$(function(){ $.get('career-utility.xml',function(myData){
$(myData).find('listgroup').each(function(index){
var count = index;
var listGroup = $(this);
var listGroupTitle = $(this).attr('title');
var shortNote = $(this).attr('shortnote');
var subLink = $(this).find('sublist');
var firstList = $(this).find('list');
$('.grouplist').append('<div class="list-group"><h3>'+listGroupTitle+'</h3><ul class="level-one level' + count + '"></ul></div>');
firstList.each(function(listnum){
var subList = $(this).text();
var subListLeveltwo = $(this).find('sublist').text();
if(subListLeveltwo==''){
$('<li>'+subList+'</li>').appendTo('ul.level'+count+'');
}
else{
$('<li class="new">'+subList+'</li>').appendTo('ul.level'+count+'');
}
})
})
})
})
© Stack Overflow or respective owner