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.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 8-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Languages for Dynamic Web Documents
Server-Side vs. Client-Side Scripting Languages
15-Jun-15 Ajax with XML. Displaying theAjax response Here is the previous code for dealing with a non-XML response: function alertContents(http_request)
IS 373—Web Standards Todd Will
XML Session 3 Data Islands Document Object Model ParsingNamespaces.
Introduction to Web Interface Technology (CSE2030)
1 JavaScript & AJAX CS , Spring JavaScript.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
4.1 JavaScript Introduction
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
 Introduction to XML Introduction to XML  Features of XML Features of XML  Syntax of XML Syntax of XML  Syntax rules of XML document Syntax rules.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
1 Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COT 6930 Advanced Internet Programming Dr. Roy Levow Day 2.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
XML eXtensible Markup Language w3c standard Why? Store and transport data Easy data exchange Create more languages WSDL (Web Service Description Language)
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Unit 1 – Web Concepts Instructor: Brent Presley. ASSIGNMENT Read Chapter 1 Complete lab 1 – Installing Portable Apps.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Parsing with DOM using MSXML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
DOM Robin Burke ECT 360. Outline XHTML in Schema JavaScript DOM (MSXML) Loading/Parsing Transforming parameter passing DOM operations extracting data.
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.
XML 6.4 DOM 6. The XML ‘Alphabet Soup’ XMLExtensible Markup Language Defines XML documents XSLExtensible Stylesheet Language Language for expressing stylesheets;
ASP Introduction Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Weekend MS CS Program Internet and Web Technologies COT 5930 Web Project Development - Ajax Dr. Roy Levow, Associate Chair & Professor
1 Dr Alexiei Dingli XML Technologies XML Advanced.
J.Holvikivi 1 Ajax & scripts Jaana Holvikivi Metropolia.
How do I use HTML and XML to present information?.
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.
CIS 275—Web App Dev I XML. 2 Introduction to XMLXML XML stands for ________________________. HTML was designed to display data. XML was designed to _________.
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.
Lecture Note 1: Getting Started With ASP.  Introduction to ASP  Introduction to ASP An ASP file can contain text, HTML tags and scripts. Scripts in.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
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.
1 Dr Alexiei Dingli XML Technologies SAX and DOM.
Introduction to the Document Object Model Eugenia Fernandez IUPUI.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
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 –
CIS 375—Web App Dev II DTD. 2 Introduction to DTD DTD stands for ______________________. The purpose of a DTD is to define the legal building blocks of.
XML Parser using JavaScript. 2 Microsoft To manipulate an XML document in javascript, you need an XML parser. Today all browsers come with in-built parsers.
 defined as Extensible Markup Language (XML) is a set of rules for encoding documents  Defines structure and data.
ASHIMA KALRA  INTRODUCTION OF XML INTRODUCTION OF XML  XML FEATURES XML FEATURES  XML SYNTAX XML SYNTAX  XML ELEMENTS XML ELEMENTS  XML ATTRIBUTES.
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
Dave Salinas. What is XML? XML stands for eXtensible Markup Language Markup language, like HTML HTML was designed to display data, whereas XML was designed.
Document Object Model.  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM presents an.
ASP Syntax Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
XML DOM Week 11 Web site:
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
Active Server Pages v.s. Java Server Pages Presenters: Lan Guo Qunying Fan Pei-Xun Wu Date:
Introduction to AJAX Pat Morin COMP Outline What is AJAX? – History – Uses – Pros and Cons An XML HTTP Transaction – Creating an XMLHTTPRequest.
In this session, you will learn to:
Introduction to ASP By “FlyingBono” 2009_01 By FlyingBono 2009_01
Jim Fawcett CSE791 – Distributed Objects Spring 2001
Introduction to Internet Programming
Week 11 Web site: XML DOM Week 11 Web site:
In this session, you will learn to:
Ajax with XML 23-Feb-19.
Ajax with XML 27-Feb-19.
CS 240 – Advanced Programming Concepts
Presentation transcript:

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 an XML document can be accessed and _____________. The XML DOM is designed to be used with any programming language and any __________ system. The DOM represents a ______ view of the XML document. The documentElement is the top-level of the tree. This element has one or many ___________ that represent the branches of the tree.

3 Common Node Types Node TypeExample Document type Processing instruction Element Carlsberg Attributetype="beer“ TextCarlsberg

4 Parsing the DOM The Microsoft XML _______ is a COM component that comes with Microsoft Internet Explorer 5.0.COM The Microsoft XMLDOM parser: Supports JavaScript, VBScript, Perl, VB, Java, C++, … Supports W3C XML 1.0 and XML DOM Supports DTD and validation Creating an XML document object using JavaScript, _________, and VBScript in ASP: var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") set xmlDoc = CreateObject("Microsoft.XMLDOM") set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")

5 Loading XML Files and Text Loading a file var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load("note.xml") // processing the document goes here Loading text (see example)example var text=" “ text=text+" Tove Jani “ text=text+" Reminder “ text=text+" Don't forget me this weekend! “ text=text+" " var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.loadXML(text) // processing the document goes here

6 Parser Errors The parseError _______ can be used to extract error information from the Microsoft XML parser, but is not a part of the W3C DOM standard. The following ___________ code accesses the parseError object: var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load("note_error.xml") document.write(" Error Code: ") document.write(xmlDoc.parseError.errorCode) document.write(" Error Reason: ") document.write(xmlDoc.parseError.reason) document.write(" Error Line: ") document.write(xmlDoc.parseError.line) Try it Yourself or just look at the XML file Try it Yourselflook at the XML file

7 DOM Validator To help you validate your xml, w3schools has used Microsoft's XML parser to create an xml validator. Paste your XML in the text area, and validate it by pressing the validate button. You can also validate your XML files simply by typing the URL of your XML file and pressing the submit button. NOTE: If you get an error when accessing this file, it is because your IE security settings do not allow access across domains. To correct, select Tools, Internet Options, Security, Custom Level…, Miscellaneous, Access data sources across domains

8 Accessing the DOM The following VBScript code examples traverse an XML node _____, and display the XML elements in the browser: JUST TRY IT and also try the CD catalog example JUST TRY ITCD catalog example The following JavaScript reads XML data from an XML document and writes the XML data into (waiting) ______ elements. JUST TRY IT Addressing elements by number is not the preferred way to extract XML elements. Using ______ is better. JUST TRY IT

9 The HttpRequest Object The httpRequest object is not a part of the W3C DOM __________. How to get an XML file from the server using the httpRequest object (works only in IE): Try it Yourself or Try this example Try it YourselfTry this example How to get an XML file from the server using the httpRequest object (works only in IE): Try it Yourself You can also send an XML document to an ASP page on the server, analyze the request, and send back the result. Try it Yourself (see the w3Schools page for ASP code) Try it Yourself

10 DOM NodeTypes Nodes are separated into different types. The XML file used in the examples: note_special.xmlnote_special.xml We traverse the file to get the nodeType of the nodes: NodeTypeNodeType We traverse the file to get the nodeName of the same nodes: NodeNameNodeName We traverse the file to get the nodeValue of the same nodes: NodeValueNodeValue In IE5, you can also get the nodeType as a string, with the.nodeTypeString property: NodeTypeStringNodeTypeString