<
Script logage
=
"
JavaScript
"
>
VAR
DOC
=
New
ActiveXObject
"
Msxml2.domdocument
"
);
//
IE5.5 , CreateObject ("Microsoft.xmldom")
//
Load document
//
Doc.Load ("B.XML");
//
Create a file header
VAR
p
=
Doc.createProcessinginstruction
"
xml
"
,
"
Version = '1.0' encoding = 'GB2312'
"
);
//
Add a file header
Doc.appendchild (p);
//
Get root point when loading directly
//
Var root = doc.documentelement;
//
Create root contacts in two ways
//
Var root = doc.createElement ("students");
VAR
root
=
Doc.createnode
1
,
"
Students
"
,
""
);
//
Create sub-contact
VAR
n
=
Doc.createnode
1
,
"
TTYP
"
,
""
);
//
Specify sub-contact text
//
n.Text = "this is a test";
//
Create a sunwork point
VAR
o
=
Doc.createElement
"
SEX
"
); O.Text
=
"
male
"
;
//
Specify its text
//
Create properties
VAR
r
=
Doc.createAttribute
"
id
"
R.Value
=
"
Test
"
;
//
Add attribute
N.SetaTRibutenode (R);
//
Create a second attribute
VAR
R1
=
Doc.createAttribute
"
Class
"
R1.Value
=
"
TT
"
;
//
Add attribute
n.settributenode (r1);
//
Delete the second attribute
N.RemoveAttribute
"
Class
"
);
//
Add Sun Jia
N.Appendchild (O);
//
Add text contact
N.Appendchild (Doc.createTextNode
"
This is a text node.
"
));
//
add notes
N.Appendchild (Doc.createComment)
"
this is a comment
"
));
//
Add sub-contact
Root.Appendchild (n);
//
Copy contact
VAR
M
=
N.Clonenode
True
Root.Appendchild (M);
//
Delete contact
Root.removechild (root.childnodes
0
));
//
Create data segment
VAR
c
=
Doc.createcDatasection
"
this is a cdata
"
C.Text
=
"
Hi, CDATA
"
;
//
Add data segment
Root.Appendchild (C);
//
Add root contact
Doc.Appendchild (root);
//
Find contacts
VAR
a
=
Doc.getElementsBytagname
"
TTYP
"
);
//
Var a = doc.selectnodes ("// TTYP");
//
Display the properties of the change point
for
(
VAR
i
=
0
i
<
a.length; i
)
...
{Alert (a [i] .xml; for (var j = 0; j
// XML Save (need to be on the server, client with fso) // Doc.save (); // View Root contact XML IF (n) ... {Alert (n.ownerDocument.xml); // -> Script > NULL