XML DOM createElement() Method
Complete Document Object Reference
Definition and Usage
The createElement() method creates an element node.
This method returns an Element object.
Syntax
| Parameter |
Description |
| name |
A string that specifies the name for the element node |
Example
The following code fragment loads "books.xml"
into xmlDoc using
loadXMLDoc() and adds an element node with a containing text node to each <book> element:
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
var newel,newtext;
for (i=0;i<x.length;i++)
{
newel=xmlDoc.createElement('edition');
newtext=xmlDoc.createTextNode('First');
newel.appendChild(newtext);
x[i].appendChild(newel);
}
|
Try-It-Yourself Demos
createElement()
and createTextNode() - Create an element node and a text node
Complete Document Object Reference
Want To Be A Web Master?
If you want to be a Web Master, you will have to host your web site with an ISP (Internet Service Provider).
MaximumASP offers seven different configurations of dedicated servers to meet your Windows and .NET hosting needs.
Hosted on our multi-tiered Enterprise Class network, these servers provide the performance, security and reliability
you need to host your high end web sites and applications.
Visit MaximumASP
|