w3schools
Search W3Schools :  
  
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
YOUR FREE WEBSITE

Free Flash Website
Free Flash Templates
Free Web Design

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

XML DOM Examples

DOM Examples
DOM Validator

 

XML DOM insertBefore() Method


Element Object Reference Complete Element Object Reference

Definition and Usage

The insertBefore() method inserts a new child node before an existing child node.

This method returns the new child node.

Syntax

elementNode.insertBefore(new_node,existing_node)

Parameter Description
new_node Required. The node to insert
existing_node Required. The existing node. The new node is inserted before this node.


Example

The following code fragment loads "books.xml" into xmlDoc using loadXMLDoc(), creates a new <book> node and inserts it before the last <book> element:

Example

xmlDoc=loadXMLDoc("books.xml");

newNode=xmlDoc.createElement("book");

x=xmlDoc.documentElement;
y=xmlDoc.getElementsByTagName("book")[3];

x.insertBefore(newNode,y);

Try it yourself

Element Object Reference Complete Element Object Reference



W3Schools Certification

W3Schools' Online Certification Program

The perfect solution for professionals who need to balance work, family, and career building.

More than 3500 certificates already issued!

The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

 
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
Get a Freelancer
Download XML editor
FREE Flash Website
FREE Web Templates
FLIGHT TICKETS
Find the cheapest flight
to any destination now!
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
STATISTICS
Browser Statistics
Browser OS
Browser Display
W3Schools.com HOME | TOP | PRINT | FORUM | ABOUT
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.