w3schools    w3Schools
Search W3Schools :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
XML DOM Tutorial
DOM HOME
DOM Introduction
DOM Nodes
DOM Node Tree
DOM Parsing
DOM Load Function
DOM Methods
DOM Accessing
DOM Node Info
DOM Node List
DOM Traversing
DOM Browsers
DOM Navigating

Manipulate Nodes
DOM Get Values
DOM Change Nodes
DOM Remove Nodes
DOM Replace Nodes
DOM Create Nodes
DOM Add Nodes
DOM Clone Nodes
DOM HttpRequest

XML DOM Reference
DOM Node Types
DOM Node
DOM NodeList
DOM NamedNodeMap
DOM Document
DOM DocumentImpl
DOM DocumentType
DOM ProcessingInstr
DOM Element
DOM Attribute
DOM Text
DOM CDATA
DOM Comment
DOM HttpRequest
DOM ParseError Obj
DOM Parser Errors

DOM Summary

Examples
DOM Examples
DOM Validator

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Tutorials
W3Schools Forum

Helping W3Schools

 

XML DOM - The Element Object

prev next

The Element object represents an element in an XML document.


The Element object

The Element object represents an element in an XML document. Elements may contain attributes, other elements, or text. If an element contains text, the text is represented in a text-node.

IMPORTANT! Text is always stored in text nodes. A common error in DOM processing is to navigate to an element node and expect it to contain the text. However, even the simplest element node has a text node under it. For example, in <year>2005</year>, there is an element node (year), and a text node under it, which contains the text (2005).

Because the Element object is also a Node, it inherits the Node object's properties and methods.

IE: Internet Explorer, F: Firefox, O: Opera, W3C: World Wide Web Consortium (Internet Standard)

Element Object Properties

Property Description IE F O W3C
attributes Returns a NamedNodeMap of attributes for the element 5 1 9 Yes
baseURI Returns the absolute base URI of the element No 1 No Yes
childNodes Returns a NodeList of child nodes for the element 5 1 9 Yes
firstChild Returns the first child of the element 5 1 9 Yes
lastChild Returns the last child of the element 5 1 9 Yes
localName Returns the local part of the name of the element No 1 9 Yes
namespaceURI Returns the namespace URI of the element No 1 9 Yes
nextSibling Returns the node immediately following the element 5 1 9 Yes
nodeName Returns the name of the node, depending on its type 5 1 9 Yes
nodeType Returns the type of the node 5 1 9 Yes
ownerDocument Returns the root element (document object) for an element 5 1 9 Yes
parentNode Returns the parent node of the element 5 1 9 Yes
prefix Sets or returns the namespace prefix of the element No 1 9 Yes
previousSibling Returns the node immediately before the element 5 1 9 Yes
schemaTypeInfo Returns the type information associated with the element     No Yes
tagName Returns the name of the element 5 1 9 Yes
textContent Sets or returns the text content of the element and its descendants No 1 No Yes
text Returns the text of the node and its descendants. IE-only property 5 No No No
xml Returns the XML of the node and its descendants. IE-only property 5 No No No

Element Object Methods

Method Description IE F O W3C
appendChild() Adds a new child node to the end of the list of children of the node 5 1 9 Yes
cloneNode() Clones a  node 5 1 9 Yes
compareDocumentPosition() Compares the document position of two nodes No 1 No Yes
getAttribute() Returns the value of an attribute 5 1 9 Yes
getAttributeNS() Returns the value of an attribute (with a namespace) No 1 9 Yes
getAttributeNode() Returns an attribute node as an Attribute object 5 1 9 Yes
getAttributeNodeNS() Returns an attribute node (with a namespace) as an Attribute object No   9 Yes
getElementsByTagName() Returns a NodeList of matching element nodes, and their  children 5 1 9 Yes
getElementsByTagNameNS() Returns a NodeList of matching element nodes (with a namespace), and their  children No 1 9 Yes
getFeature(feature,version) Returns a DOM object which implements the specialized APIs of the specified feature and version     No Yes
getUserData(key) Returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key     No Yes
hasAttribute() Returns whether an element has any attributes matching a specified name 5 1 9 Yes
hasAttributeNS() Returns whether an element has any attributes matching a specified name and namespace No 1 9 Yes
hasAttributes() Returns whether the element has any attributes 5 1 9 Yes
hasChildNodes() Returns whether the element has any child nodes 5 1 9 Yes
insertBefore() Inserts a new child node before an existing child node 5 1 9 Yes
isDefaultNamespace(URI) Returns whether the specified namespaceURI is the default     No Yes
isEqualNode() Checks if two nodes are equal No No No Yes
isSameNode() Checks if two nodes are the same node No 1 No Yes
isSupported(feature,version) Returns whether a specified feature is supported on the element     9 Yes
lookupNamespaceURI() Returns the namespace URI matching a specified prefix No 1 No Yes
lookupPrefix() Returns the prefix matching a specified namespace URI No 1 No Yes
normalize() Puts all text nodes underneath this element (including attributes) into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes 5 1 9 Yes
removeAttribute() Removes a specified attribute 5 1 9 Yes
removeAttributeNS() Removes a specified attribute (with a namespace) No 1 9 Yes
removeAttributeNode() Removes a specified attribute node 5 1 9 Yes
removeChild() Removes a child node 5 1 9 Yes
replaceChild() Replaces a child node 5 1 9 Yes
setUserData(key,data,handler) Associates an object to a key on the element     No Yes
setAttribute() Adds a new attribute 5 1 9 Yes
setAttributeNS() Adds a new attribute (with a namespace)   1 9 Yes
setAttributeNode() Adds a new attribute node 5 1 9 Yes
setAttributeNodeNS(attrnode) Adds a new attribute node (with a namespace)     9 Yes
setIdAttribute(name,isId) If the isId property of the Attribute object is true, this method declares the specified attribute to be a user-determined ID attribute     No Yes
setIdAttributeNS(uri,name,isId) If the isId property of the Attribute object is true, this method declares the specified attribute (with a namespace) to be a user-determined ID attribute     No Yes
setIdAttributeNode(idAttr,isId) If the isId property of the Attribute object is true, this method declares the specified attribute to be a user-determined ID attribute     No Yes


prev next


The tools you need to build your web project!

Instant Demo

Ektron CMS400.NET Version 7.6 delivers all of the flexibility and features you need to deploy the Web site you want, quickly and efficiently.

learn more...

 

 

 

6 ways to take your site to the next level with Ektron:

Social Networking Create site stickiness through social networking. Keep it personal, relevant and interactive and they'll come back for more.
Open API Keep it open. Your site needs to be ready and able to connect to outside services. Ektron's open API gives you maximum flexibility.
Document Management Streamline content and document management. Users need to quickly and intuitively find and add information.
Content Authors Empower your content authors. Reduce IT bottlenecks by allowing business users to create and edit Web content and forms.
Taxonomy Climb to the top of search rankings. SEO tools, URL aliasing and eCommerce for your digital marketing strategy
Web 2.0 Tools Add powerful Web 2.0 tools like blogs, wikis, forums, geo-mapping, rating systems and RSS feeds easily.
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today.

 
WEB HOSTING
dotnetbutton
Dynamic button image generation
$15 Domain Name
Registration
Save $20 / year!
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting
WEB BUILDING
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Download XML editor
FREE Flash Website
FREE Web Templates
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
Home HOME or Top of Page Validate   Validate   W3C-WAI level A conformance icon Printer Friendly  Printer Friendly

W3Schools is for training only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user.
While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright 1999-2009 by Refsnes Data. All Rights Reserved.