generate html using javascript and xml smartly