EunsooD

javascript로 xml데이터 읽기 본문

카테고리 없음

javascript로 xml데이터 읽기

EunsooD 2014. 10. 14. 11:47
반응형

스크립트로 xml 데이터 읽을 때


var xmlDoc=null;
    if (window.ActiveXObject)
    {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    }
    else if (document.implementation.createDocument)
    {
      xmlDoc=document.implementation.createDocument("","",null);
    }
    else
    {
      alert('XML을 사용못하는 브라우저임');
    }
    if (xmlDoc!=null)
    {
      xmlDoc.async=false;
      xmlDoc.load("/real_hot_issue.xml");

      var x=xmlDoc.getElementsByTagName("item");
      for (i=0;i<x.length;i++)
      {
            document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
            document.write(x[i].getElementsByTagName("nowrank")[0].childNodes[0].nodeValue);
      }
    }

반응형
Comments