--Use javascript to import data and modify the data in xml.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Test</title>
</head>
<link rel="Stylesheet" type="text/css" href=""/>
<script language="javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
//Load xml and xsl files
var oxml = new XmlDom();
var oxsl = new XmlDom();
= false;//Synchronous loading
= false;
("");
("");
if ( != 0) {
var oError = ;
alert("An error occurred:\nError Code: "
+ + "\n"
+ "Line: " + + "\n"
+ "Line Pos: " + + "\n"
+ "Reason: " + );
}
if ( != 0) {
var oError = ;
alert("An error occurred:\nError Code: "
+ + "\n"
+ "Line: " + + "\n"
+ "Line Pos: " + + "\n"
+ "Reason: " + );
}
var sResult = (oxsl);
//alert(sResult);
//Some operations
function btnSub(){
var fes = [0].elements;
for(var i = 0;i<;i++){
var name = fes[i].name;
if(('re_')!=-1){
var xmlid=(3,);
var obj;//= ("items_1");// There is no such method in the dom of xml?
var oItems1 = ("items");// It can also be implemented using xpath.
var oItems2 = ("item");
for(var j=0;j<;j++){
if(oItems1[j].getAttribute('id')==xmlid){
obj = oItems1[j];
break;
}
}
for(var j=0;j<;j++){
if(oItems2[j].getAttribute('id')==xmlid){
obj = oItems2[j];
break;
}
}
if(obj){
[0].text = fes[i].value;
}else{
alert("Items or item" with id "+xmlid+" was not found in xml);
}
}
if(('of_')!=-1){
var xmlid=(3,);
var oItems1 = ("items");
var oItems2 = ("item");
for(var j=0;j<;j++){
if(oItems1[j].getAttribute('id')==xmlid){
obj = oItems1[j];
break;
}
}
for(var j=0;j<;j++){
if(oItems2[j].getAttribute('id')==xmlid){
obj = oItems2[j];
break;
}
}
if(obj){
[1].text = fes[i].value;
}else{
alert("Items or item" with id "+xmlid+" was not found in xml);
}
}
}
alert();
//alert([2].xml);
return false;
}
</script>
</head>
<body>
<form name="form1" action="" method="post" onsubmit="return btnSub();">
<script type="text/javascript">
(sResult);
</script>
</form>
</body>
</html>
Auxiliary files required
--Style file
The effect of text box
--Browser and operating system recognition (taken from JavaScript advanced programming)
--Unified XML operations of different browsers (taken from JavaScript advanced programming)
Previous page12Read the full text