XML의 내용을 JQuery로 불러와서 Array로 파싱.
.get 으로 xml의 내용을 가져와서 .each 로 루프하면서 출력하는 테스트 .
querystring 으로 넘어오는 값도 받아서 적용한다.
Aptana 로 로컬에서 Javasrcipt 테스트 중. 완전 좋다.

<!DOCTYPE html PUBLIC "-//W3C//  DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>jQuery -> XML -> Array : Parse </title>
        <script src="jquery-latest.min.js" type="text/javascript">
        </script>
        <script type="application/javascript">
            
            
            
            $(function(){
            
                // 원하는 파라키터 호출
                var param01 = querySt("anum");
                //document.write(param01);
                $('#param01').html(param01);
                
                $.get("hello.xml", {}, function(xml){
                    $("item", xml).each(function(i){
                        var title = $(this).find("title");
                        
                        alert("title 의 개수는 총 " + $(this).find("title").size() + " 개 입니다.");
                        
                        $.each(title, function(j){
                        
                            $("#content_xml").append("j = " + j + " , " + $(this).text() + "<br />");
                            
                        });
                        
                        $("#contents").append(title.text());
                    });
                });
                
                $('p').each(function(index){
                    $(this).attr({
                        'id': "para-" + index
                    });
                });
                $('#btn').click(function(){
                    alert($('#para-1').text()); //태그내의 텍스트 읽어오기
                });
                
                
                // QueryString 호출
                function querySt(ji){
                    hu = window.location.search.substring(1);
                    gy = hu.split("&");
                    
                    for (i = 0; i < gy.length; i++) {
                        ft = gy[i].split("=");
                        if (ft[0] == ji) {
                            return ft[1];
                        }
                    }
                }
                
                
            }); //close $(
        </script>
    </head>
    <body>
        <div id='content_xml'>
        </div>
        <br/>
        <div id='param01'>
        </div>
        <br/>
        <div id='contents'>
        </div>
        <p>
            C#
        </p>
        <p>
            ASP.NET
        </p>
        <p>
            SilverLight
        </p>
        <input type="button" id="btn" value="동적으로 생성된 id로 접근" />
    </body>
</html>

hello.xml
<?xml version="1.0" encoding="utf-8"?>
 <item>
     <title>Ezra Pound</title>
     <title>Edward Nom</title>
     <title>Nippon Ds</title>
     <title>Chin</title>
     <title>wani</title>
     <title>金洪完</title>
     <title>上海</title>
     <title>Ngio.co.kr</title>
 </item>

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2011/03/25 13:51 2011/03/25 13:51
, , , ,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5994

Trackback URL : http://tcbs17.cafe24.com/tc/trackback/5994

« Previous : 1 : ... 61 : 62 : 63 : 64 : 65 : 66 : 67 : 68 : 69 : ... 324 : Next »

블로그 이미지

- 홍반장

Archives

Recent Trackbacks

Calendar

«   2024/04   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        
Statistics Graph

Site Stats

Total hits:
182574
Today:
570
Yesterday:
506