DOM Programming The Document Object Model standardises  what an application can see of the XML data  how it can access it An XML structure is a tree.

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

XML: Extensible Markup Language
UFCEKG-20-2 Data, Schemas & Applications Lecture 5 XML & PHP.
14-Jun-15 DOM. SAX and DOM SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files DOM is a W3C standard SAX is an ad-hoc.
We Need Smart XML Processing HTML has ultra-complex semantics XML has no semantics Something must bridge the gap  A program ?  A clear set of data semantics?
Displaying and Using XML There are simple ways to use or display XML  CSS stylesheets  Data Source Objects  DHTML & Data Islands In later lessons we.
1 Overview of XPath. 2 XPATH XPath expressions are used to locate nodes in XML documents The list of nodes located by an XPath expression is called a.
1 COS 425: Database and Information Management Systems XML and information exchange.
Apache DOM Parser©zwzOctober 24, 2002 Wenzhong Zhao Department of Computer Science The University of Kentucky.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 XML Taken from Chapter 7.
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.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Lecture 7 of Advanced Databases XML Querying & Transformation Instructor: Mr.Ahmed Al Astal.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
Lecture 6 of Advanced Databases XML Querying & Transformation Instructor: Mr.Eyad Almassri.
17 Apr 2002 XML Programming - DOM Andy Clark. DOM Design Premise Derived from browser document model Defined in IDL – Lowest common denominator programming.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
DOM Robin Burke ECT 360. Outline XHTML in Schema JavaScript DOM (MSXML) Loading/Parsing Transforming parameter passing DOM operations extracting data.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
XML DOM Functionality in.NET DSK Chakravarthy
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
Computing & Information Sciences Kansas State University Thursday, 15 Mar 2007CIS 560: Database System Concepts Lecture 24 of 42 Thursday, 15 March 2007.
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.
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.
Declaratively Producing Data Mash-ups Sudarshan Murthy 1, David Maier 2 1 Applied Research, Wipro Technologies 2 Department of Computer Science, Portland.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
[ Part III of The XML seminar ] Presenter: Xiaogeng Zhao A Introduction of XQL.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
XML Study-Session: Part III
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.
Apache DOM Parser©zwzOctober 24, 2002 Wenzhong Zhao Department of Computer Science The University of Kentucky.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
COP 3813 Intro to Internet Computing Prof. Roy Levow XML.
1 The Information School of the University of Washington Nov 1fit dom © 2006 University of Washington Document Object Model (DOM)
Computing & Information Sciences Kansas State University Friday, 20 Oct 2006CIS 560: Database System Concepts Lecture 24 of 42 Friday, 20 October 2006.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
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.
DOM (Document Object Model) - Parsing and Reading HTML and XML -
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
Document Object Model (DOM). Outline  Introduction of DOM  Overview of DOM  DOM Relationships  Standard DOM.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
13-Mar-16 DOM. 2 Difference between SAX and DOM DOM reads the entire XML document into memory and stores it as a tree data structure SAX reads the XML.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
USING ANDROID WITH THE DOM. Slide 2 Lecture Summary DOM concepts SAX vs DOM parsers Parsing HTTP results The Android DOM implementation.
XML DOM Week 11 Web site:
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
21-Jun-16 Document Object Model DOM. SAX and DOM SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files DOM is a W3C.
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
XML. Contents  Parsing an XML Document  Validating XML Documents.
Programming Web Pages with JavaScript
Unit 4 Representing Web Data: XML
Querying and Transforming XML Data
Introduction to the Document Object Model
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Chapter 7 Representing Web Data: XML
Week 11 Web site: XML DOM Week 11 Web site:
DOM Document Object Model.
Basic HTML and Embed Codes
DOM 8-Dec-18.
Document Object Model (DOM): Objects and Collections
JavaScript and the DOM MIS 2402 Maxwell Furman Department of MIS
Presentation transcript:

DOM Programming The Document Object Model standardises  what an application can see of the XML data  how it can access it An XML structure is a tree of Nodes  elements– text – entities  attributes– processing instructions

DOM Nodes and NodeLists All nodes have  type getNodeType()  name getNodeName()  value getNodeValue() Nodes are arranged in  NodeLists e.g. child elements of  NamedNodeMaps e.g. attributes of

DOM Node Traversal Methods Element nodes have  parent Node getParentNode()  children Node getFirstChild() Node getLastChild() NodeList getChildNodes()  siblings Node getNextSibling() Node getPreviousSibling()  attributes NamedNodeMap getAttributes()

DOM NodeLists NodeLists have  length int getLength()  individual items Node item(n) NamedNodeMaps have  length int getLength()  individual items Node item(n)  named items Node getNamedItem(str)

DOM Demonstration JavaScript binding allows Dynamic XML dom.html contains a demonstration of DOM access of an XML document. dom.html

Microsoft Extensions to DOM New functions combine DOM and XPath  NodeList selectNodes("XPath expression")  Node selectSingleNode("XPath expression") (see later lesson for XPath) DOM calls renamed as properties e.g. n.getNodeType() becomes n.nodeType and documentElement.getChildNodes() becomes documentElement.childNodes The property. text applied to an element represents the concatenation of its textual contents and those of all its subelements.

Link Checking: Sample DOM Use Often an application needs to  search through the entire document for a single piece of data every occurrence of some data Need functions to  traverse the complete document hierarchy checkAllNodes()  test each node checkThisNode()

Link Checking: Outline Framework function checkAllNodes(n){ checkThisNode(n); if(n.hasChildNodes){... } function checkThisNode(n){ if(n==null)return;... } Iterate around all children (see next page) Perform application- specific test (see sample file)

Link Checking: Code Details To iterate around all children var children=n.childNodes var i=0; for(i=0; i<children.length; i++) checkAllNodes(children.item(i)) Useful fragments for app-specific test  n.nodeName is element name / #PCDATA  n.getAttribute(name) returns value of the named attribute

Link Checking: Putting It Together To start the recursion off, call checkAllNodes( xmlstuff.XMLDocument.documentElement); See checkLinks.html checkLinks.html

DOM Pros and Cons Pros  very powerful and flexible  good for rich, complex data and documents Cons  Must write a complex program!  Highly tedious to specify correct DOM location

XPath: DOM Path Specification Standard for declarative expression of DOM traversal  XPath navigates around the elements in an XML document  like a URL navigates around documents in the Web Also used in conjunction with new standards for queries and linking.

XPath Expressions (1) /book/chapter/title  a title element inside a chapter element inside the top-level book element /book/*/title  a title element inside any element inside the top-level book element /book//title  a title element anywhere inside the top-level book element

XPath Expressions (2) para/quote  a quote element inside a paragraph element inside the current element./para/quote  same as above../para/quote  a quote element inside a paragraph element inside the parent of the current element

XPath Expressions (3) title|heading|label  either a title or a heading or a label element  the number attribute of a chapter element inside a top-level book element

XPath Expressions (4) chapter[title]  a chapter element with a title element chapter[title="Gone with the Wind"]  a chapter element whose title element has the contents "Gone with the Wind" chapter[1]  the first chapter element  para elements with a security attribute set

XPath Pros and Cons XPath is like regular expressions for XML Pros  Simple, expressive  Good for both documents and data Cons  Can’t DO anything with it – must use in conjunction with DOM or XSLT processing