xml을 읽어와서 리스트를 출력하고 그중 링크를 하나 클릭하면 해당 내용을 출력하는 소스인데요.

내용 출력 부분을 간소화 시킬수 있을까요? 웬지 검색을 두번 하는게 비효율적인것 같아서..

 

$.ajax({
    url: '../xml/post.xml', // 읽어올 문서
    type: 'GET', // 방식
    dataType: 'xml', // 문서 타입
    timeout: 1000, // 시간 설정
    error: function(){ // 로딩 에러시
        alert('Error loading XML document');
    },
    success: function(xml){
        $i = 0;
        $(xml).find('post').each(function(){
            $i++;
            if($i>15) return false;

            var no = $(this).find("no").text();
            var category = $(this).find("category").text(); 
            var title = $(this).find("title").text(); 
            var author = $(this).find("author").text();
            var date = $(this).find("date").text();
            var read = $(this).find("read").text();
            var vote = $(this).find("vote").text();
    
            var view_text = "<tr><td class=\"no\">" + no + "</td><td class=\"category show-for-medium\">" + category + "</td><td class=\"title\"><a class=\"post-link\" href=\"#\" data-open=\"post-layer\">" + title + "</a></td><td class=\"author show-for-medium\">" + author + "</td><td class=\"date\">" + date + "</td><td class=\"read\">" + read + "</td><td class=\"vote show-for-large\">" + vote + "</td><tr>"; 
            $("#post-list").prepend(view_text);
            
        });

        $(".post-link").click(function () {
            $i = $(this).parent().parent().children(".no").text();
            
            $(xml).find('post').each(function(idx){
                if($i==(++idx)){
                    var category = $(this).find("category").text(); 
                    var title = $(this).find("title").text(); 
                    var author = $(this).find("author").text();
                    var date = $(this).find("date").text();
                    var read = $(this).find("read").text();
                    var vote = $(this).find("vote").text();
                    var content = $(this).find("content").text();
            
                    var view_post = "<h1>" + category + "|" + title + "</h1><p>" + author + " " + date + " " + read + " " + vote + "</p><p>" + content + "</p>"; 
                    $("#post-main").html(view_post);

                    return false;
                }                
            });

        });
    }

});