0% found this document useful (0 votes)
25 views7 pages

XML Midterms Exam Reviewer

Uploaded by

G-Rien Jadear
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views7 pages

XML Midterms Exam Reviewer

Uploaded by

G-Rien Jadear
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Week 5 – XML DOM WebApp : XML - based Web Application

XML DOM

• XML DOM stands for XML Document Object Model .


• It is the foundation of XML which contains a set of standard functions for accessing and
manipulating contents in an XML document .

XML DOM Tree Structure


• XML DOM is presented in a tree structure .
• A tree structure revolves around hierarchical information units called nodes .
● Types of nodes
● ocument node
● Element node
● Text nodes
● Attribute Nodes
● Comment Nodes

Relationship of Nodes

• A node in a tree structure follows a hierarchical relationship .


Basic Terminologies
• Parent node
• Child node
• Sibling nodes
• Root node
• Leaf node
XML DOM Properties
Below is a list of XML DOM Properties
• nodeName - The name of the node .
• nodeType – The node’s type
• nodeValue – Value of the node
• attributes – An array of attributes and values
• parentNode – This returns the parent of a node . It returns null if there is no parent
• childNodes – array of child nodes
• firstchild , lastchild – references the first and last child of a node
• previousSibling , nextSibling – references the previous and next sibling of a node
• appendChild () – inserts an element at the end of a given element’s children
• removeChild () – removes an element from the parent
• insertBefore () – inserts a new node before the given node
• replaceChild () – replaces an existing node inside the parent with a new one .
• documentElement () – references the root document element
• createElement () – creates a new element that can be inserted in the document
• createTextNoe () – creates a new text node .
• createComment () – creates a new comment
• createCDATASection () - creates a new CDATA Section
• getElementsByTagName () – returns array of tags that match given tag name
• getElementById () - returns a single element with a given ID
• getAttribute () – gets the value of a given attribute on an element
• setAttribute () – sets the value of an attribute on an element
• removeAttribute () – removes an attribute from an element
• innerHTML – gets or sets the HTML content of the given tag
• data – gets the text data of an Element, Comment, or Text node
Week 6 – Using XML DOM

Accessing a Node

Using looping

Creating and Adding a Node


Using createElement () function

Other useful XML DOM functions for creating and adding nodes
• createAttribute – used for creating attributes for elements
• setAttribute – used for setting attribute values
• createText – used for creating text nodes
• createComment – used creating comment nodes
Removing and replacing a node
Removing a node

Replacing a node

Changing Text node value


• You can change text node values directly using the nodevalue property .
Week 7 – Introduction to XPath

XPath
• XPath is a standard way of accessing/selecting data in XML .
• It is a fundamental part of other XML related technologies such as XSLT and
XQuery .

Xpath Nodes
• XPath is also based around nodes .
• The XPath Nodes concept and relationship is similar to XML DOM nodes .

W3C Recommended
• The XPath is a W3C standard .

XPath Application
• XPath defines paths on XML documents.
• These paths are similar to the directories we use to access files on our computers.
XPath Path Expressions
The following are some of the path expressions used in XPath

You might also like