Name
createElement: tagName
Synopsis
This creates a new, empty Element
node for use within the parent
document. The element name is given as an argument to the method.
The resulting Element
node
belongs to the parent Document
object, but is not part of the document element hierarchy. See the
NOT_SUPPORTED_ERR [unsigned short,
value: 9] reference later in this chapter for more
information about how the document hierarchy manipulation methods
are used.
Argument
- tagName: DOMString
The XML name used to create the new
Element
node. This name is assigned to thenodeName
attribute of the resultingElement
node.
Return value
The new Element
object.
Exception
- INVALID_CHARACTER_ERR
Indicates that the name you passed to
createElement( )
is not a legal XML name. See Chapter 2 for the XML restrictions on name construction.
Java binding
public Element createElement(String tagName) throws DOMException;
Java example
// Create the new my_tag Element Element elOut = doc.createElement("my_tag");
Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.