USING ANDROID WITH THE DOM. Slide 2 Lecture Summary DOM concepts SAX vs DOM parsers Parsing HTTP results The Android DOM implementation.

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Web architectures – Laurea Specialistica in Informatica – Università di Trento Java XML parsing.
Advertisements

The Java Platform and XML Portable Code, Portable Data James Duncan Davidson Staff Engineer, Sun Microsystems, Inc.
SE 5145 – eXtensible Markup Language (XML ) DOM (Document Object Model) (Part II – Java API) /Spring, Bahçeşehir University, Istanbul.
USING ANDROID WITH THE INTERNET. Slide 2 Network Prerequisites The following must be included so as to allow the device to connect to the network The.
Lecture 4 Java Interfaces (review of inheritance and abstract classes) The XML DOM Java Examples Homework 3.
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.
©Silberschatz, Korth and Sudarshan10.1Database System Concepts W3C Activities HTML: is the lingua franca for publishing on the Web XHTML: an XML application.
1 XML and Data Management XML Processors Hachim Haddouti Al Akhawayn University SSE
Xerces The Apache XML Project Yvonne Yao. Introduction Set of libraries that provides functionalities to parse XML documents Set of libraries that provides.
1 Processing XML with Java Representation and Management of Data on the Internet A comprehensive tutorial about XML processing with JavaXML processing.
1 Processing XML with Java CS , Spring 2008/9.
MC365 XML Parsers. Today We Will Cover: An overview of the Java API’s used for XML processing Creating an XML document in Java Parsing an XML document.
Apache DOM Parser©zwzOctober 24, 2002 Wenzhong Zhao Department of Computer Science The University of Kentucky.
SE 5145 – eXtensible Markup Language (XML ) DOM (Document Object Model) (Part I) /Spring, Bahçeşehir University, Istanbul.
Processing of structured documents Spring 2003, Part 5 Helena Ahonen-Myka.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools Leonidas Fegaras.
17 Apr 2002 XML Programming: JAXP Andy Clark. Java API for XML Processing Standard Java API for loading, creating, accessing, and transforming XML documents.
Lecture 7 of Advanced Databases XML 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.
Java WWW Week 10 Version 2.1 Mar 2008 Slide Java (JSP) and XML  Format of lecture: What is XML? A sample XML file… How to use.
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.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools.
XML Parsers Overview  Types of parsers  Using XML parsers  SAX  DOM  DOM versus SAX  Products  Conclusion.
Parsing with DOM using MSXML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML 6.4 DOM 6. The XML ‘Alphabet Soup’ XMLExtensible Markup Language Defines XML documents XSLExtensible Stylesheet Language Language for expressing stylesheets;
Intro to XML Originally Presented by Clifford Lemoine Modified by Box.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Scripting with the DOM Ellen Pearlman Eileen Mullin Programming the Web.
Sheet 1XML Technology in E-Commerce 2001Lecture 3 XML Technology in E-Commerce Lecture 3 DOM and SAX.
Consuming eXtensible Markup Language (XML) feeds.
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.
XML Refresher Course Bálint Joó School of Physics University of Edinburgh May 02, 2003.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools.
XML Study-Session: Part III
Document Object Model DOM. Agenda l Introduction to DOM l Java API for XML Parsing (JAXP) l Installation and setup l Steps for DOM parsing l Example –Representing.
SNU OOPSLA Lab. DOM/SAX Applications The ubiquitous XML(9) © copyright 2001 SNU OOPSLA Lab.
SDPLNotes 3.2: DOM1 3.2 Document Object Model (DOM) n How to provide uniform access to structured documents in diverse applications (parsers, browsers,
Apache DOM Parser©zwzOctober 24, 2002 Wenzhong Zhao Department of Computer Science The University of Kentucky.
SAX2 and DOM2 Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
 defined as Extensible Markup Language (XML) is a set of rules for encoding documents  Defines structure and data.
XML and Object Serialization. Structure of an XML Document Header Root Element Start Tags / End Tags Element Contents – Child Elements – Text – Both (mixed.
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
Web services. DOM parsing and SOAP.. Summary. ● Exercise: SAX-Based checkInvoice(), ● push parsing, ● event-based parsing, ● traversal order is depth-first.
©Silberschatz, Korth and Sudarshan10.1Database System Concepts W3C - The World Wide Web Consortium W3C - The World Wide Web Consortium.
Document Object Model (DOM). Outline  Introduction of DOM  Overview of DOM  DOM Relationships  Standard DOM.
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.
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
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.
Week-9 (Lecture-1) XML DTD (Data Type Document): An XML document with correct syntax is called "Well Formed". An XML document validated against a DTD is.
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
XML. Contents  Parsing an XML Document  Validating XML Documents.
{ XML Technologies } BY: DR. M’HAMED MATAOUI
New Xml Converters General presentation of Xml converters The old way
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
New Xml Converters General presentation of Xml converters The old way
Intro to XML.
Java/XML.
{ XML Technologies } BY: DR. M’HAMED MATAOUI
XML in Web Technologies
DOM Document Object Model.
Processing XML.
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
DOM 8-Dec-18.
WaysInJavaToParseXML
Document Object Model (DOM): Objects and Collections
DOM 24-Feb-19.
CS 240 – Advanced Programming Concepts
XML Programming in Java
WaysInJavaToParseXML
Presentation transcript:

USING ANDROID WITH THE DOM

Slide 2 Lecture Summary DOM concepts SAX vs DOM parsers Parsing HTTP results The Android DOM implementation

Slide 3 SAX vs DOM Parsers SAX parsers read an XML document sequentially They are fast DOM parsers read an entire document into a tree-based structure They are slower because of this We will use a DOM parser here

Slide 4 Origins of the DOM classes The XML related classes we use are derived from different sources Java Android W3c

Slide 5 Classes We Need DocumentBuilderFactory connects applications to parsers DocumentBuilder is the parser that builds the DOM tree Document contains a reference to the in- memory document

Slide 6 Classes We Need InputSource is the SAX parser we will use to read the XML document This SAX parser is needed by the DOM parser to read the document StringReader reads the string as a stream NodeList contains a list of DOM nodes Node is a DOM node

Slide 7 Creating an XML Parser In summary, we have a string that needs to be converted to an in-memory XML DOM object tree XML and Java take a “layered” approach to do this Create a parser Connect the parser to an input stream Parse the document

Slide 8 Creating the XML Parser Create a DocumentBuilder via the DocumentBuilderFactory Call the parse method on an input stream to read and parse the document Using the Document object, navigate and work with the in-memory XML document Its really the same object as the JavaScript document object

Slide 9 The DocumentBuilderFactory Class It lets applications get a parser that produces XML object trees from XML documents This is pretty much the same DOM with which you are familiar (JavaScript) As the name implies, we use a factory class and newInstance method to create the DocumenntBuilder

Slide 10 The DocumentBuilderFactory Class Example to create the factory DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();

Slide 11 The DocumentBuilder Class It’s the DocumentBuilder that has the APIs used to parse the XML into a Document

Slide 12 The Document Class It’s very similar to the JavaScript document class. After all, the DOM is the DOM It contains the parsed document Call the parse method to parse the document

Slide 13 The Document Class (Methods) getDocumentElement() returns the root node (Node type) getElementsByTagName() gets a NodeList of elements having the same element name getElementByID() get a Node having the corresponding ID

Slide 14 The NodeList Class It’s just a simple list getLength() gets the number of nodes in the list Item(int index) returns a specific node We just enumerate with a loop

Slide 15 Node Types Every node has a type and node of different types behave differently Element Attribute Text

Slide 16 The Node Class getNodeName() gets the name of the element if this is an element node and the name of the attribute if this is an attribute node getNodeType() gets the type of node (element, text, attribute, etc…) getNodeValue() Returns null for elements Returns the text content for text nodes Returns the attribute value for attribute nodes

Slide 17 The Node Class hasAttributes() returns true for element nodes if the node has attributes hasChildren() returns true for element nodes if the node has child nodes getAttributes() returns a NamedNodeMap of attributes

Slide 18 The Node class Methods to navigate the tree getChildNodes() gets a NodeList of all children getFirstChild() get a Node of first child or null getLastChild() gets a Node of last child or null getNextSibling() gets the next sibling Node or null

Slide 19 Attributes Call getAttributes() on a node to return a NamedNodeMap Call getNamedItem() to get the value corresponding to the attribute name