반응형
<script language="javascript">
xmldoc = new ActiveXObject("Msxml2.DOMDocument");
xmldoc.async =false;
var root,name,att_f,att_l;
var names = [["기수","김"],["길동","홍"],["현아","신"],["나라","장"]]
var root = xmldoc.createElement("simple");
for(var i=0; i <names.length; i++)
{
name = xmldoc.createElement("name");
att_f = xmldoc.createAttribute("first");att_f.nodeValue = names[i][0];
att_l = xmldoc.createAttribute("last");att_l.nodeValue = names[i][1];
name.attributes.setNamedItem(att_f);
name.attributes.setNamedItem(att_l);
root.appendChild(name);
}
xmldoc.documentElement = root;
alert(xmldoc.xml);
xmldoc = new ActiveXObject("Msxml2.DOMDocument");
xmldoc.async =false;
var root,name,att_f,att_l;
var names = [["기수","김"],["길동","홍"],["현아","신"],["나라","장"]]
var root = xmldoc.createElement("simple");
for(var i=0; i <names.length; i++)
{
name = xmldoc.createElement("name");
att_f = xmldoc.createAttribute("first");att_f.nodeValue = names[i][0];
att_l = xmldoc.createAttribute("last");att_l.nodeValue = names[i][1];
name.attributes.setNamedItem(att_f);
name.attributes.setNamedItem(att_l);
root.appendChild(name);
}
xmldoc.documentElement = root;
alert(xmldoc.xml);
</script>
'IT > xml' 카테고리의 다른 글
XSLT2.0 namespace 설정법 (0) | 2017.12.07 |
---|---|
[XML]XML documentElement 사용 예제 (0) | 2011.05.24 |
[XML] XPath함수인 format-number, count(), sum() 사용법 (0) | 2011.05.12 |
[XML] CSS에서 background 적용 방법 (0) | 2011.04.26 |
[XML] element 전역 설정 (0) | 2011.04.05 |