Lecture 2 : Understanding the Document Object Model (DOM) UFCFR5-15-3 Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.

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

1/7 ITApplications XML Module Session 8: Introduction to Programming with XML.
XML: Extensible Markup Language
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 12 Extensible Stylesheet Language Transformations : XSLT.
UFCEKG-20-2 Data, Schemas & Applications Lecture 5 XML & PHP.
XPath Eugenia Fernandez IUPUI. XML Path Language (XPath) a data model for representing an XML document as an abstract node tree a mechanism for addressing.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
CS 898N – Advanced World Wide Web Technologies Lecture 15: Dynamic HTML Chin-Chih Chang
CS 898N – Advanced World Wide Web Technologies Lecture 22: Applying XML Chin-Chih Chang
CNIT 133 Interactive Web Pags – JavaScript and AJAX Review HTML5.
The Document Object Model (DOM) & Asynchronous Javascript And XML (AJAX) : an introduction UFCEKG-20-2 : Data, Schemas and Applications.
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.
1 Document Object Model (DOM) MV4920 – XML 24 September 2001 Simon R. Goerger MAJ, US Army
XML and XPath. Web Services: XML+XPath2 EXtensible Markup Language (XML) a W3C standard to complement HTML A markup language much like HTML origins: structured.
1/17 ITApplications XML Module Session 7: Introduction to XPath.
Introduction to XPath Web Engineering, SS 2007 Tomáš Pitner.
XML and its applications: 4. Processing XML using PHP.
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.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
Working with Objects Creating a Dynamic Web Page.
Lecture 14 Extensible Stylesheet Language Transformations : XSLT.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
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 Programming the WWW I CMSC Summer 2003 Lecture 7.
XPath Aug ’10 – Dec ‘10. XPath   XML Path Language   Technology that allows to select a part or parts of an XML document to process   XPath was.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
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.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Lecture 3 : PHP5-DOM API UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
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.
SDPLNotes 3.2: DOM1 3.2 Document Object Model (DOM) n How to provide uniform access to structured documents in diverse applications (parsers, browsers,
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.
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
 defined as Extensible Markup Language (XML) is a set of rules for encoding documents  Defines structure and data.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
Structured-Document Processing Languages Spring 2004 Course Review Repetitio mater studiorum est!
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
Martin Kruliš by Martin Kruliš (v1.1)1.
DOM (Document Object Model) - Parsing and Reading HTML and XML -
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.
Lecture 15 Extensible Stylesheet Language Transformations : XSLT.
1 The tree data structure Outline In this topic, we will cover: –Definition of a tree data structure and its components –Concepts of: Root, internal, and.
XML DOM Week 11 Web site:
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
THE DOM.
DHTML.
XML in Web Technologies
Database Processing with XML
JavaScript Introduction
Week 11 Web site: XML DOM Week 11 Web site:
The Document Object Model
HTML A brief introduction HTML.
More Sample XML By Sadia Anjum.
Document Object Model (DOM): Objects and Collections
XML and its applications: 4. Processing XML using PHP
XML Programming in Java
Presentation transcript:

Lecture 2 : Understanding the Document Object Model (DOM) UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong

DOM : What is it? An object-based, language-neutral, application programming interface (API) for XML and HTML documents - allows programs and scripts to build documents, navigate their structure, add, modify or delete elements and content - provides a foundation for developing querying, filtering, transformation, rendering etc. applications on top of DOM implementations In contrast to “Serial Access XML” (sax) a good way to think of the DOM is as “Directly Obtainable in Memory” (dom) objects representing the nodes, attributes and content of documents

Based on O-O concepts: methodsmethods (to access or change object’s state) interfacesinterfaces (declaration of a set of methods) objectsobjects (encapsulation of data and methods) Roughly similar to the XSLT/XPath data model  a parse tree Tree-like structure implied by the abstract relationships defined by the programming interfaces; Does not necessarily reflect data structures used by an implementation (but probably does) DOM : What is it? (2)

o Language-independence: DOM interfaces are defined using OMG Interface Definition Language (IDL; Defined in Corba Specification) Corba Specification o Language bindings (implementations of DOM interfaces) defined in the Recommendation for Java and ECMAScriptECMAScript (standardised JavaScript) DOM : What is it? (3)

“Dynamic HTML" is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated. The W3C has received several submissions from members companies on the way in which the object model of HTML documents should be exposed to scripts. These submissions do not propose any new HTML tags or style sheet technology. The W3C DOM Activity is working hard to make sure interoperable and scripting-language neutral solutions are agreed upon. W3C DOM : Why?

The DOM specification 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. DOM parts/levels (1)

DOM parts/levels (2)

o Level 0: Not really a standard level. Refers to models developed by browser vendors for handling documents prior to a standard. o Level 1: First recommendation from W3C for a DOM Standard. Includes two parts: a core (covers XML & HTML) and an HTML- only section. o Level 2: Includes additions for events and style sheets. Supported by current versions of the most popular browsers. o Level 3: Events published 2012 – now complete. XPATH features added. see: DOM parts/levels (3)

o Level 1 and subsequent DOM Levels perceive objects using a hierarchical view. Instead of identifying specific HTML tag names, this view works through the idea of nodes in a tree diagram. Each node has the potential to be a parent, sibling, or child node of other nodes in the document. This model may be a little trickier to program, at first, but saves us from having to know the names of all the elements in our document. DOM Level 1 :

DOM Level 1 (HTML example) :

Example XML document Joseph Michael Bloggs Joe Mr 2 Gloucester Road Bristol Avon BS2 4QS DOM Level 1 (xml example) :

patient name title address fax tel first middle last previous preferred street1 street2 street3 city county postcode home mobile JosephMichaelBloggs Joe 2 Gloucester Rd BristolAvon BS2 4QS Mr nhs-no KEY element content attribute DOM tree view of example XML document DOM Level 1 (xml example) :

xpath axes (node sets) xpath has thirteen axis child parent descendent ancestor descendent-of-self ancestor-of-self following-sibling preceding-sibling following preceding attribute namespace self

o All pages must be well-formed (XHTML/HTML) documents. o All pages must include a valid DOCTYPE. o You must include all text inside valid HTML/XHTML elements. o Identify relevant elements using the id attribute. DOM suggestions & recommendations :

o id is an HTML/XHTML attribute that provides an internal identifier for an HTML/XHTML element (tag). o When can use the id attribute to uniquely identify an element in order to read and/or manipulate its contents. The HTML/XHTML id Attribute