Hello.
In Javascript, XLM Create, XML File Save.
In Javascript, XLM Create, XML File Save.
Code:
<root>
<SCHOOL id = THOMAS JEFFERSON>
<NAME id = "James"> 160 </NAME>
<NAME id = "Mateo"> 157 </NAME>
<NAME id = "Mason"> 170 </NAME>
<NAME id = "Henry"> 165 </NAME>
<NAME id = "Jack"> 180 </NAME>
<NAME id = "Christian"> 172 </NAME>
</SCHOOL>
<SCHOOL id = PHILLIPS EXETER ACADEMY>
<NAME id = "Micah"> 145 </NAME>
<NAME id = "Jordan"> 156 </NAME>
</SCHOOL>
<SCHOOL id = Deerfield Academy>
<NAME id = "Samuel"> 189 </NAME>
<NAME id = "Jayden"> 136 </NAME>
<NAME id = "Jacob"> 173 </NAME>
</SCHOOL>
<SCHOOL id = Groton School>
<NAME id = "Greyson"> 159 </NAME>
<NAME id = "Sntiago"> 163 </NAME>
<NAME id = "Colton"> 189 </NAME>
<NAME id = "Roman"> 201 </NAME>
<NAME id = "Parker"> 156 </NAME>
</SCHOOL>
<SCHOOL id = Milton Academy>
<NAME id = "Cameron"> 159 </NAME>
</SCHOOL>
:
:
:
:
Infinity
</root>
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script language="javascript">
function XMLCreate()
{
var xmlDoc=new ActiveXObject("microsoft.XMLDOM");
//<?xml version='1.0' encoding='euc-kr'?>
var PInode=xmlDoc.createProcessingInstruction("xml", "version='1.0' encoding='euc-kr'");
//2. Root Element <compactdiscs></compactdiscs>
var rootNode=xmlDoc.createElement("compactdiscs");
//3. Element
var compactdiscNode=xmlDoc.createElement("compactdisc");
var titleNode=xmlDoc.createElement("title");
var priceNode=xmlDoc.createElement("price");
//4. Text Node
var titleTextNode=xmlDoc.createTextNode("OST");
var priceTextNode=xmlDoc.createTextNode("8000");
//
xmlDoc.appendChild(PInode);
xmlDoc.appendChild(rootNode);
rootNode.appendChild(compactdiscNode);
compactdiscNode.appendChild(titleNode);
compactdiscNode.appendChild(priceNode);
titleNode.appendChild(titleTextNode);
priceNode.appendChild(priceTextNode);
//Attribute
titleNode.setAttribute("numberoftracks", "3");
//Output
document.all.txtResult.value=xmlDoc.xml;
}
</script>
</head>
<body>
<h3>XML Make </h3>
<button onclick="XMLCreate()">XML Make</button>
<br/>
<textarea cols="80" rows="20" name="txtResult"></textarea>
</body>
</html>
Last edited: