XML DOM Week 11 Web site:

Slides:



Advertisements
Similar presentations
XML IV. The Document Object Model The Document Object model is a hierarchical structure of an XML document. It provides a means for accessing, and manipulating.
Advertisements

Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
Tutorial 16 Working with Dynamic Content and Styles.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
AJAX (Asynchronous JavaScript and XML) Amit Jain CS 590 – Winter 2008.
Tutorial 11 Creating XML Document
SD2520 Databases using XML and JQuery
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
JS: Document Object Model (DOM)
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
A really fairly simple guide to: mobile browser-based application development (part 4, JQuery & DOM) Chris Greenhalgh G54UBI / Chris Greenhalgh.
Lecture 11 – DOM Scripting SFDV3011 – Advanced Web Development Reference: 1.
Working with Objects Creating a Dynamic Web Page.
CIS 375—Web App Dev II DOM. 2 Introduction to DOM The XML Document ________ Model (DOM) is a programming interface for XML documents. It defines the way.
Parsing with DOM using MSXML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Working with the XML Document Object Model ©NIITeXtensible Markup Language/Lesson 7/Slide 1 of 44 Objectives In this lesson, you will learn to: *Identify.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
5.2 DOM (Document Object Model). 2 Motto: To write it, it took three months; to conceive it three minutes; to collect the data in it — all my life. —F.
1 Dr Alexiei Dingli XML Technologies XML Advanced.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
XML Document Object Model Anthony Borquez. The Document Object Model a programming interface for HTML and XML documents. It defines the way a document.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Scripting with the DOM Ellen Pearlman Eileen Mullin Programming the Web.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
IS2802 Introduction to Multimedia Applications for Business Lecture 1: Introduction to IS2802 Rob Gleasure
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 10.
1 Dr Alexiei Dingli XML Technologies SAX and DOM.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
Introduction to the Document Object Model Eugenia Fernandez IUPUI.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
TOPIC II Dynamic HTML Prepared by: Nimcan Cabd Cali.
 defined as Extensible Markup Language (XML) is a set of rules for encoding documents  Defines structure and data.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
Accessing XML Documents Using DOM ©NIITeXtensible Markup Language/Lesson 8/Slide 1 of 23 Objectives In this lesson, you will learn to: * Use XML DOM objects.
DOM (Document Object Model) - Parsing and Reading HTML and XML -
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
Document Object Model (DOM). Outline  Introduction of DOM  Overview of DOM  DOM Relationships  Standard DOM.
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I HTML DOM part I Jongwook.
Document Object Model.  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM presents an.
Create Element, Remove Child. The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”
JS: Document Object Model (DOM) DOM stands for Document Object Model, and allows programmers generic access to: DOM stands for Document Object Model, and.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
THE DOM.
DHTML.
Programming Web Pages with JavaScript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Unit M Programming Web Pages with
Applied Online Programming
Introduction to the Document Object Model
Unit M Programming Web Pages with
Application with Cross-Platform GUI
Week 11 Web site: XML DOM Week 11 Web site:
The Document Object Model
DOM Document Object Model.
More Sample XML By Sadia Anjum.
CHAPTER 7 JavaScripts & HTML Documents
Document Object Model (DOM): Objects and Collections
2017, Fall Pusan National University Ki-Joune Li
Class 4: Building Interactive Web Pages
Creating dynamic/interactive web pages
Presentation transcript:

XML DOM Week 11 Web site:

XML DOM (Document Object Model) The XML DOM defines a standard way for accessing and manipulating XML documents. The DOM presents an XML document as a tree-structure.

What is the DOM? The DOM is a W3C (World Wide Web Consortium) standard. The DOM defines a standard for accessing documents like XML and HTML: "The W3C Document Object Model (DOM) is a platform and language- neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document." The DOM is separated into 3 different parts / levels:  Core DOM - standard model for any structured document  XML DOM - standard model for XML documents  HTML DOM - standard model for HTML documents The DOM defines the objects and properties of all document elements, and the methods (interface) to access them.

Document Object Model (DOM) What is the HTML DOM?  The HTML DOM defines the objects and properties of all HTML elements, and the methods (interface) to access them. What is the XML DOM?  The XML DOM is: A standard object model for XML A standard programming interface for XML Platform- and language-independent A W3C standard The XML DOM defines the objects and properties of all XML elements, and the methods (interface) to access them. In other words: The XML DOM is a standard for how to get, change, add, or delete XML elements. In the DOM, everything in an XML document is a node.

DOM Nodes According to the DOM, everything in an XML document is a node. The DOM says:  The entire document is a document node  Every XML element is an element node  The text in the XML elements are text nodes  Every attribute is an attribute node  Comments are comment nodes

Text is always Stored in Text Nodes A common error in DOM processing is to expect an element node to contain text. However, the text of an element node is stored in a text node. In this example: 2005, the element node, holds a text node with the value "2005". "2005" is not the value of the element!

The XML DOM Node Tree The XML DOM views an XML document as a tree- structure. The tree structure is called a node- tree. All nodes can be accessed through the tree. Their contents can be modified or deleted, and new elements can be created. The node tree shows the set of nodes, and the connections between them. The tree starts at the root node and branches out to the text nodes at the lowest level of the tree.

Node Parent, Children, and Siblings The nodes in the node tree have a hierarchical relationship to each other. The terms parent, child, and sibling are used to describe the relationships. Parent nodes have children. Children on the same level are called siblings (brothers or sisters). Properties of Nodes:  In a node tree, the top node is called the root  Every node, except the root, has exactly one parent node  A node can have any number of children  A leaf is a node with no children  Siblings are nodes with the same parent

XML file T1 A T2 A T3 A

Nodes Relationship The following image illustrates a part of the node tree and the relationship between the nodes:

Node Relationship (continue…) Because the XML data is structured in a tree form, it can be traversed without knowing the exact structure of the tree and without knowing the type of data contained within. NOTE: Most browsers have a built-in XML parser to read and manipulate XML. The parser converts XML into a JavaScript accessible object (the XML DOM).

XML Parser The XML DOM contains methods (functions) to traverse XML trees, access, insert, and delete nodes. However, before an XML document can be accessed and manipulated, it must be loaded into an XML DOM object. An XML parser reads XML, and converts it into an XML DOM object that can be accessed with JavaScript. Most browsers have a built-in XML parser. NOTE: from our AJAX example, responseXML is an XML DOM object.

Programming Interface The DOM models XML as a set of node objects. The nodes can be accessed with JavaScript or other programming languages. The programming interface to the DOM is defined by a set standard properties and methods. Properties are often referred to as something that is (i.e. nodename is "book"). Methods are often referred to as something that is done (i.e. delete "book").

XML DOM Properties These are some typical DOM properties:  x.nodeName - the name of x  x.nodeValue - the value of x  x.parentNode - the parent node of x  x.childNodes - the child nodes of x  x.attributes - the attributes nodes of x Note: In the list above, x is a node object.

XML DOM Methods  x.getElementsByTagName(name) - get all elements with a specified tag name  x.appendChild(node) - insert a child node to x  x.removeChild(node) - remove a child node from x Note: In the list above, x is a node object

Sample JavaScript Coding var xmlDoc, x; xmlDoc = xmlHttp.responseXML; x = xmlDoc.getElementsByTagName("title"); var y = x[0].childNodes[0].nodeValue; var z = x[1].childNodes[0].nodeValue; // or var y = xmlDoc.getElementsByTagName ("title")[0].childNodes[0].nodeValue; var z = xmlDoc.getElementsByTagName ("title")[1].childNodes[0].nodeValue;

Sample JavaScript Coding (continue…) Explained: xmlDoc - the XML DOM object created by the parser. getElementsByTagName("title")[0] - the first element childNodes[0] - the first child of the element (the text node) nodeValue - the value of the node (the text itself)

Ajax – Asynchronous JavaScript and XML ote.html ax_sample_js.txt ote_php.txt

Homework 10 ork/10_homework.html ork/10_homework.html ork/10_homework.xml ork/10_homework.xml