SDPL 2002Notes 3.2: Document Object Model1 The Misconceived Web n The original vision of the WWW was as a hyperlinked document-retrieval system. n It did.

Slides:



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

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.
SE 5145 – eXtensible Markup Language (XML ) DOM (Document Object Model) (Part II – Java API) /Spring, Bahçeşehir University, Istanbul.
SDPL 2002Notes 3: XML Processor Interfaces1 3.3 JAXP: Java API for XML Processing n How can applications use XML processors? –A Java-based answer: through.
SAX A parser for XML Documents. XML Parsers What is an XML parser? –Software that reads and parses XML –Passes data to the invoking application –The application.
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.
XML DOM and SAX Parsers By Omar RABI. Introduction to parsers  The word parser comes from compilers  In a compiler, a parser is the module that reads.
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.
By: Shawn Li. OUTLINE XML Definition HTML vs. XML Advantage of XML Facts Utilization SAX Definition DOM Definition History Comparison between SAX and.
The Document Object Model (DOM) & Asynchronous Javascript And XML (AJAX) : an introduction UFCEKG-20-2 : Data, Schemas and Applications.
1 XML Data Management 4. Domain Object Model Werner Nutt.
SDPL 2003Notes 3: XML Processor Interfaces1 3. XML Processor APIs n How can applications manipulate structured documents? –An overview of document parser.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
1 Document Object Model (DOM) MV4920 – XML 24 September 2001 Simon R. Goerger MAJ, US Army
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
Structured-Document Processing Languages Spring 2011 Course Review Repetitio mater studiorum est!
XML Data Processing and Transformation ดร. มารุต บูรณรัช : หัวข้อพิเศษด้านเทคโนโลยีสารสนเทศขั้นสูง.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
SDPL 2002Notes 3.2: Document Object Model1 XML 접근과 관련된 자료.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Lecture 2 : Understanding the Document Object Model (DOM) UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.
Adminisztratív November 24.-én az előadás és a gyakorlat elmarad A nagy gyakorlati feladatok beszedése a december 1.-én tartandó gyakorlatra tolódik A.
Structured-Document Processing Languages Spring 2005 Course Review Repetitio mater studiorum est!
SDPL 2002Notes 3: XML Processor Interfaces1 3. XML Processor APIs n How can applications manipulate structured documents? –An overview of document parser.
SDPL 20113: XML APIs and SAX1 3. XML Processor APIs n How can (Java) applications manipulate structured (XML) documents? –An overview of XML processor.
XML Parsers Overview  Types of parsers  Using XML parsers  SAX  DOM  DOM versus SAX  Products  Conclusion.
SDPLNotes 3.3: DOM Examples1 3.3 DOM Examples 1. DOM processing in a Web browser –a toy "XML database browser" –with JavaScript and MS Internet Explorer.
Electronic Commerce COMP3210 Session 4: Designing, Building and Evaluating e-Commerce Initiatives – Part II Dr. Paul Walcott Department of Computer Science,
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.
The XML Document Object Model (DOM) Aug’10 – Dec ’10.
XML 6.4 DOM 6. The XML ‘Alphabet Soup’ XMLExtensible Markup Language Defines XML documents XSLExtensible Stylesheet Language Language for expressing stylesheets;
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
XML Processing in Java. Required tools Sun JDK 1.4, e.g.: JAXP (part of Java Web Services Developer Pack, already in Sun.
Java API for XML Processing (JAXP) Dr. Rebhi S. Baraka Advanced Topics in Information Technology (SICT 4310) Department of Computer.
SDPL 2002Notes 3.2: Document Object Model1 3.2 Document Object Model (DOM) n How to provide uniform access to structured documents in diverse applications.
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.
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.
C# and Windows Programming XML Processing. 2 Contents Markup XML DTDs XML Parsers DOM.
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.
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.
Schema Data Processing
Structured-Document Processing Languages Spring 2007 Course Review Repetitio mater studiorum est!
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
Structured-Document Processing Languages Spring 2004 Course Review Repetitio mater studiorum est!
Web services. DOM parsing and SOAP.. Summary. ● Exercise: SAX-Based checkInvoice(), ● push parsing, ● event-based parsing, ● traversal order is depth-first.
Document Object Model (DOM). Outline  Introduction of DOM  Overview of DOM  DOM Relationships  Standard DOM.
SDPL 20063: XML Processor Interfaces1 3. XML Processor APIs n How can (Java) applications manipulate structured (XML) documents? –An overview of XML processor.
7-Mar-16 Simple API XML.  SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files  DOM is a W3C standard  SAX is an.
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.
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:
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.
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
In this session, you will learn to:
Java/XML.
{ XML Technologies } BY: DR. M’HAMED MATAOUI
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
DOM 8-Dec-18.
A parser for XML Documents
DOM 24-Feb-19.
XML Programming in Java
Presentation transcript:

SDPL 2002Notes 3.2: Document Object Model1 The Misconceived Web n The original vision of the WWW was as a hyperlinked document-retrieval system. n It did not anticipate presentation, session, or interactivity. n If the WWW were still consistent with TBL's original vision, Yahoo would still be two guys in a trailer.

SDPL 2002Notes 3.2: Document Object Model2 How We Got Here n Rule Breaking n Corporate Warfare n Extreme Time Pressure

SDPL 2002Notes 3.2: Document Object Model3 The Miracle n It works! n Java didn't. n Nor did a lot of other stuff.

SDPL 2002Notes 3.2: Document Object Model4 The Scripted Browser n Introduced in Netscape Navigator 2 (1995) n Eclipsed by Java Applets n Later Became the Frontline of the Browser War n Dynamic HTML n Document Object Model (DOM)

SDPL 2002Notes 3.2: Document Object Model5 Viewing XML n XML is designed to be processed by computer programs, not to be displayed to humans n Nevertheless, almost all current Web browsers can display XML documents –They do not all display it the same way –They may not display it at all if it has errors n This is just an added value. Remember: HTML is designed to be viewed, XML is designed to be used

SDPL 2002Notes 3.2: Document Object Model6 Stream Model n Stream seen by parser is a sequence of elements n As each XML element is seen, an event occurs –Some code registered with the parser (the event handler) is executed n This approach is popularized by the Simple API for XML (SAX) n Problem: –Hard to get a global view of the document –Parsing state represented by global variables set by the event handlers

SDPL 2002Notes 3.2: Document Object Model7 Data Model n The XML data is transformed into a navigable data structure in memory –Because of the nesting of XML elements, a tree data structure is used –The tree is navigated to discover the XML document n This approach is popularized by the Document Object Model (DOM) n Problem: –May require large amounts of memory –May not be as fast as stream approach »Some DOM parsers use SAX to build the tree

SDPL 2002Notes 3.2: Document Object Model8 SAX and DOM n SAX and DOM are standards for XML parsers –DOM is a W3C standard –SAX is an ad-hoc (but very popular) standard n There are various implementations available n Java implementations are provided as part of JAXP (Java API for XML Processing) n JAXP package is included in JDK starting from JDK 1.4 –Is available separately for Java 1.3

SDPL 2002Notes 3.2: Document Object Model9 Difference between SAX and DOM n DOM reads the entire document into memory and stores it as a tree data structure n SAX reads the document and calls handler methods for each element or block of text that it encounters n Consequences: –DOM provides "random access" into the document –SAX provides only sequential access to the document –DOM is slow and requires huge amount of memory, so it cannot be used for large documents –SAX is fast and requires very little memory, so it can be used for huge documents »This makes SAX much more popular for web sites

SDPL 2002Notes 3.2: Document Object Model10 Parsing with SAX n SAX uses the source-listener-delegate model for parsing XML documents –Source is XML data consisting of a XML elements –A listener written in Java is attached to the document which listens for an event –When event is thrown, some method is delegated for handling the code

SDPL 2002Notes 3.2: Document Object Model11 Callbacks n SAX works through callbacks: –The program calls the parser –The parser calls methods provided by the program parse(...) The SAX parser Program main(...) startDocument(...) startElement(...) characters(...) endElement( ) endDocument( )

SDPL 2002Notes 3.2: Document Object Model12 Problems with SAX n SAX provides only sequential access to the document being processed n SAX has only a local view of the current element being processed –Global knowledge of parsing must be stored in global variables –A single startElement() method for all elements »In startElement() there are many “if-then-else” tests for checking a specific element »When an element is seen, a global flag is set »When finished with the element global flag must be set to false

SDPL 2002Notes 3.2: Document Object Model13 DOM n DOM represents the XML document as a tree –Hierarchical nature of tree maps well to hierarchical nesting of XML elements –Tree contains a global view of the document »Makes navigation of document easy »Allows to modify any subtree »Easier processing than SAX but memory intensive! n As well as SAX, DOM is an API only –Does not specify a parser –Lists the API and requirements for the parser n DOM parsers typically use SAX parsing

SDPL 2002Notes 3.2: Document Object Model14 Document Object Model (DOM) n How to provide uniform access to structured documents in diverse applications (parsers, browsers, editors, databases)? n Overview of W3C DOM Specification –second one in the “XML-family” of recommendations »Level 1, W3C Rec, Oct »Level 2, W3C Rec, Nov »Level 3, W3C Working Draft (January 2002) n What does DOM specify, and how to use it?

SDPL 2002Notes 3.2: Document Object Model15 DOM: What is it? n An object-based, language-neutral 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 n In contrast to “Serial Access XML” could think as “Directly Obtainable in Memory”

SDPL 2002Notes 3.2: Document Object Model16 DOM structure model n Based on O-O concepts: –methods (to access or change object’s state) –interfaces (declaration of a set of methods) –objects (encapsulation of data and methods) n Roughly similar to the XSLT/XPath data model (to be discussed later)  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)

SDPL 2002Notes 3.2: Document Object Model17 invoice invoicepage name addressee addressdata address form="00"type="estimatedbill" Leila Laskuprintti streetaddresspostoffice KUOPIO Pyynpolku 1 <invoice> <invoicepage form="00" <invoicepage form="00" type="estimatedbill"> type="estimatedbill"> Leila Laskuprintti Leila Laskuprintti Pyynpolku 1 Pyynpolku KUOPIO KUOPIO......Document Element NamedNodeMap Text DOM structure model

SDPL 2002Notes 3.2: Document Object Model18 Structure of DOM Level 1 I: DOM Core Interfaces –Fundamental interfaces »basic interfaces to structured documents –Extended interfaces »XML specific: CDATASection, DocumentType, Notation, Entity, EntityReference, ProcessingInstruction II: DOM HTML Interfaces –more convenient to access HTML documents –(we ignore these)

SDPL 2002Notes 3.2: Document Object Model19 DOM Level 2 –Level 1: basic representation and manipulation of document structure and content (No access to the contents of a DTD) n DOM Level 2 adds –support for namespaces –accessing elements by ID attribute values –optional features »interfaces to document views and style sheets »an event model (for, say, user actions on elements) »methods for traversing the document tree and manipulating regions of document (e.g., selected by the user of an editor) –Loading and writing of docs not specified (-> Level 3)

SDPL 2002Notes 3.2: Document Object Model20 DOM Language Bindings n Language-independence: –DOM interfaces are defined using OMG Interface Definition Language (IDL; Defined in Corba Specification) n Language bindings (implementations of DOM interfaces) defined in the Recommendation for –Java and –ECMAScript (standardised JavaScript)

SDPL 2002Notes 3.2: Document Object Model21 Document Tree Structure document document.body document. documentElement

SDPL 2002Notes 3.2: Document Object Model22 child, sibling, parent

SDPL 2002Notes 3.2: Document Object Model23 child, sibling, parent

SDPL 2002Notes 3.2: Document Object Model24 child, sibling, parent

SDPL 2002Notes 3.2: Document Object Model25 child, sibling, parent

SDPL 2002Notes 3.2: Document Object Model26 Core Interfaces: Node & its variants Node Comment DocumentFragmentAttr Text Element CDATASection ProcessingInstruction CharacterData EntityDocumentTypeNotation EntityReference “Extended interfaces” Document

SDPL 2002Notes 3.2: Document Object Model27 DOM interfaces: Node invoice invoicepage name addressee addressdata address form="00" type="estimatedbill" Leila Laskuprintti streetaddresspostoffice KUOPIOPyynpolku 1NodegetNodeTypegetNodeValuegetOwnerDocumentgetParentNode hasChildNodesgetChildNodes getFirstChildgetLastChildgetPreviousSiblinggetNextSibling hasAttributesgetAttributes appendChild(newChild)insertBefore(newChild,refChild)replaceChild(newChild,oldChild)removeChild(oldChild)Document Element NamedNodeMap Text

SDPL 2002Notes 3.2: Document Object Model28 Object Creation in DOM Each DOM object X lives in the context of a Document: X.getOwnerDocument() Each DOM object X lives in the context of a Document: X.getOwnerDocument() Objects implementing interface X are created by factory methods D.create X (…), where D is a Document object. E.g: Objects implementing interface X are created by factory methods D.create X (…), where D is a Document object. E.g: –createElement("A"), createAttribute("href"), createTextNode("Hello!") Creation and persistent saving of Document s left to be specified by implementations Creation and persistent saving of Document s left to be specified by implementations

SDPL 2002Notes 3.2: Document Object Model29 invoice invoicepage name addressee addressdata address form="00"type="estimatedbill" Leila Laskuprintti streetaddresspostoffice KUOPIO Pyynpolku 1 DocumentgetDocumentElementcreateAttribute(name)createElement(tagName)createTextNode(data)getDocType()getElementById(IdVal) Node Document Element NamedNodeMap Text DOM interfaces: Document

SDPL 2002Notes 3.2: Document Object Model30 DOM interfaces: Element invoice invoicepage name addressee addressdata address form="00"type="estimatedbill" Leila Laskuprintti streetaddresspostoffice KUOPIO Pyynpolku 1 ElementgetTagNamegetAttributeNode(name)setAttributeNode(attr)removeAttribute(name)getElementsByTagName(name)hasAttribute(name) Node Document Element NamedNodeMap Text

SDPL 2002Notes 3.2: Document Object Model31 Accessing properties of a Node –Node.getNodeName () »for an Element = getTagName() »for an Attr: the name of the attribute »for Text = "#text" etc –Node.getNodeValue() »content of a text node, value of attribute, …; null for an Element (!!) (in XSLT/Xpath: the full textual content) –Node.getNodeType() : numeric constants (1, 2, 3, …, 12) for ELEMENT_NODE, ATTRIBUTE_NODE,TEXT_NODE, …, NOTATION_NODE

SDPL 2002Notes 3.2: Document Object Model32 Content and element manipulation Manipulating CharacterData D : Manipulating CharacterData D : –D.substringData( offset, count ) –D.appendData( string ) –D.insertData( offset, string ) –D.deleteData( offset, count ) –D.replaceData( offset, count, string ) (= delete + insert) Accessing attributes of an Element object E : Accessing attributes of an Element object E : –E.getAttribute( name ) –E.setAttribute( name, value ) –E.removeAttribute( name )

SDPL 2002Notes 3.2: Document Object Model33 Additional Core Interfaces (1) NodeList for ordered lists of nodes NodeList for ordered lists of nodes –e.g. from Node.getChildNodes() or Element.getElementsByTagName("name") »all descendant elements of type "name" in document order (wild-card "*" matches any element type) Accessing a specific node, or iterating over all nodes of a NodeList : Accessing a specific node, or iterating over all nodes of a NodeList : –E.g. Java code to process all children: for (i=0; i<node.getChildNodes().getLength(); i++) process(node.getChildNodes().item(i));

SDPL 2002Notes 3.2: Document Object Model34 Additional Core Interfaces (2) NamedNodeMap for unordered sets of nodes accessed by their name: NamedNodeMap for unordered sets of nodes accessed by their name: –e.g. from Node.getAttributes() NodeList s and NamedNodeMap s are "live": NodeList s and NamedNodeMap s are "live": –changes to the document structure reflected to their contents

SDPL 2002Notes 3.2: Document Object Model35 DOM: Implementations n Java-based parsers e.g. IBM XML4J, Apache Xerces, Apache Crimson n MS IE5 browser: COM programming interfaces for C/C++ and MS Visual Basic, ActiveX object programming interfaces for script languages n XML::DOM (Perl implementation of DOM Level 1) n Others? Non-parser-implementations? (Participation of vendors of different kinds of systems in DOM WG has been active.)

SDPL 2002Notes 3.2: Document Object Model36 A Java-DOM Example A stand-alone toy application BuildXml A stand-alone toy application BuildXml –either creates a new db document with two person elements, or adds them to an existing db document –based on the example in Sect. 8.6 of Deitel et al: XML - How to program n Technical basis –DOM support in Sun JAXP –native XML document initialisation and storage methods of the JAXP 1.1 default parser (Apache Crimson)

SDPL 2002Notes 3.2: Document Object Model37 Code of BuildXml (1) n Begin by importing necessary packages: import java.io.*; import org.w3c.dom.*; import org.xml.sax.*; import javax.xml.parsers.*; // Native (parse and write) methods of the // JAXP 1.1 default parser (Apache Crimson): import org.apache.crimson.tree.XmlDocument;

SDPL 2002Notes 3.2: Document Object Model38 Code of BuildXml (2) Class for modifying the document in file fileName : Class for modifying the document in file fileName : public class BuildXml { private Document document; private Document document; public BuildXml(String fileName) { File docFile = new File(fileName); File docFile = new File(fileName); Element root = null; // doc root elemen Element root = null; // doc root elemen // Obtain a SAX-based parser: DocumentBuilderFactory factory = DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();

SDPL 2002Notes 3.2: Document Object Model39 Code of BuildXml (3) try { // to get a new DocumentBuilder: documentBuilder builder = factory.newInstance(); if (!docFile.exists()) { //create new doc document = builder.newDocument(); document = builder.newDocument(); // add a comment: // add a comment: Comment comment = document.createComment( Comment comment = document.createComment( "A simple personnel list"); "A simple personnel list"); document.appendChild(comment); document.appendChild(comment); // Create the root element: // Create the root element: root = document.createElement("db"); root = document.createElement("db"); document.appendChild(root); document.appendChild(root);

SDPL 2002Notes 3.2: Document Object Model40 Code of BuildXml (4) … or if docFile already exists: } else { // access an existing doc try { // to parse docFile try { // to parse docFile document = builder.parse(docFile); root = document.getDocumentElement(); } catch (SAXException se) { } catch (SAXException se) { System.err.println("Error: " + se.getMessage() ); System.exit(1); } /* A similar catch for a possible IOException */ /* A similar catch for a possible IOException */

SDPL 2002Notes 3.2: Document Object Model41 Code of BuildXml (5) Create and add two child elements to root : Node personNode = createPersonNode(document, "1234", "Pekka", "Kilpeläinen"); Create and add two child elements to root : Node personNode = createPersonNode(document, "1234", "Pekka", "Kilpeläinen"); root.appendChild(personNode); root.appendChild(personNode); personNode = createPersonNode(document, "5678", "Irma", "Könönen"); personNode = createPersonNode(document, "5678", "Irma", "Könönen"); root.appendChild(personNode); root.appendChild(personNode);

SDPL 2002Notes 3.2: Document Object Model42 Code of BuildXml (6) Finally, store the result document: try { // to write the // XML document to file fileName Finally, store the result document: try { // to write the // XML document to file fileName ((XmlDocument) document).write( new FileOutputStream(fileName)); ((XmlDocument) document).write( new FileOutputStream(fileName)); } catch ( IOException ioe ) { } catch ( IOException ioe ) { ioe.printStackTrace(); } ioe.printStackTrace(); }

SDPL 2002Notes 3.2: Document Object Model43 Subroutine to create person elements public Node createPersonNode(Document document, String idNum, String fName, String lName) { Element person = document.createElement("person"); Element person = document.createElement("person"); person.setAttribute("idnum", idNum); person.setAttribute("idnum", idNum); Element firstName = document. createElement("first"); Element firstName = document. createElement("first"); person.appendChild(firstName); firstName. appendChild( document. createTextNode(fName) ); firstName. appendChild( document. createTextNode(fName) ); /* … similarly for a lastName */ /* … similarly for a lastName */ return person; return person;}

SDPL 2002Notes 3.2: Document Object Model44 The main routine for BuildXml public static void main(String args[]){ if (args.length > 0) { String fileName = args[0]; BuildXml buildXml = new BuildXml(fileName); BuildXml buildXml = new BuildXml(fileName); } else { } else { System.err.println( "Give filename as argument"); }; }; } // main

SDPL 2002Notes 3.2: Document Object Model45 Summary of XML APIs n XML processors make the structure and contents of XML documents available to applications through APIs n Event-based APIs –notify application through parsing events –e.g., the SAX call-back interfaces n Object-model (or tree) based APIs –provide a full parse tree –e.g, DOM, W3C Recommendation –more convenient, but may require too much resources with the largest documents n Major parsers support both SAX and DOM