SlideShare a Scribd company logo
Understanding
  XML DOM
(W3C Standard)

         Created by :
         Om Vikram Thapa
INDEX :
   XML DOM – Introduction
   DOM Nodes (Tree Structure)
   DOM Parsing
   DOM Load Functions (in IE & FireFox)
   DOM Properties & Methods
   DOM HttpRequest
   DOM Node Types
   DOM Parse Error Objects
   Thank You!!
XML DOM (INTRODUCTION)
 The XML DOM (Document Object Model) defines a standard
   way for accessing and manipulating XML documents.

 The DOM is a W3C (World Wide Web Consortium) standard.

 DOM defines the objects and properties and methods (interface)
   to access all XML elements.

 The DOM presents an XML document as a tree structure, with
   elements, attributes, and text as nodes.

 The DOM 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
What is an XML DOM?
 The XML DOM is:
  - A standard object model for XML
  - A standard programming interface for XML
  - Platform and language-independent
  - A W3C standard
 The XML DOM defines the objects and properties
  of all XML elements, and the methods (interface) to
  access them.
 The XML DOM is a standard for how to get, change,
  add or delete XML elements.
AN EXAMPLE OF books.xml:
<bookstore>
- <book category="cooking">
 <title lang="en">Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
 <price>30.00</price>
 </book>
- <book category="language">
  <title lang="en">English</title>
 <author>Om Vikram</author>
  <year>2005</year>
  <price>50.00</price>
  </book>
  </bookstore>
XML DOM NODES :
DOM NODES DESCRIPTION
 According to the DOM, everything in an XML
   document is a node.
 The entire document is a document node .
 Every XML element is an element node .
 The text in the XML elements are text nodes .
 Every attribute is an attribute node .
 Comments are comment nodes.
In our ex.
- The root node <bookstore> holds four <book> nodes.
- Each <book> node contain 4 text node i.e.
  <title>, <author>, <year>, and <price>
XML DOM PARSING:
 Most browsers have a build-in XML parser to read
    and manipulate XML.
   The parser reads XML into memory and converts
    XML it into XML DOM object which is accessible
    from JavaScript .
   There are some differences between Microsoft's
    XML parser and the parsers used in other browsers.
   The MS parser supports loading of both XML files
    and XML strings (text)
   Other browsers use Separate parsers.
   However, all parsers contain functions to traverse
    XML trees, access, insert, and delete nodes.
Loading XML with IE using MS
XML Parser:
 The following JavaScript fragment loads an XML
  document “book.xml” into the parser :
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async="false";
  xmlDoc.load("books.xml");


 The following JavaScript fragment loads an XML text
  into the parser :
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async="false";
  xmlDoc.loadXML(txt);
Loading XML with FireFox & Other
 XML Parser :
 The following JavaScript fragment loads an XML
  document “book.xml” into the parser :

  xmlDoc=document.implementation.createDocument("","",null)
  ;
  xmlDoc.async="false";
  xmlDoc.load("books.xml");


 The following JavaScript fragment loads an XML text
  into the parser :
   parser=new DOMParser();
   xmlDoc=parser.parseFromString(txt,"text/xml");
DOM PROPERTIES & METHODS:
 XML DOM Properties:
    x.nodeName - the name of x
    x.nodeValue - the value of x
    x.parentNode - the parent node of x
    x.childNodes - the child nodes of x
    x.attributes - the attributes nodes of x
                     (where x is a node object. )
 XML DOM Methods:
      x.getElementsByTagName(name) - get all elements
       with a specified tag name
      x.appendChild(node) - insert a child node to x
      x.removeChild(node) - remove a child node from x
AN EXAMPLE :
txt=xmlObj.getElementsByTagName("title")[0].childNodes[0].nodeValue;

where
 xmlObj - the XML DOM object created by the parser.
 getElementsByTagName("title")[0] - the first <title>
  element
 childNodes[0] - the first child of the <title> element (the
  text node)
 nodeValue - the value of the node (the text itself)
NODE TYPES
NodeTypes   Named Constants
    1      ELEMENT_NODE
    2      ATTRIBUTE_NODE
    3      TEXT_NODE
    4      CDATA_SECTION_NODE
    5      ENTITY_REFERENCE_NODE
    6      ENTITY_NODE
    7      PROCESSING_INSTRUCTION_NODE
    8      COMMENT_NODE
    9      DOCUMENT_NODE
    10     DOCUMENT_TYPE_NODE
    11     DOCUMENT_FRAGMENT_NODE
    12     NOTATION_NODE
DOM PARSE ERROR OBJECTS
 When trying to open an XML document, a parser-error may
    occur.
   With the parseError object, you can retrieve the error code, the
    error text, the line that caused the error, and more.
    Property       Description
   errorCode Returns a long integer error code
   Reason         Returns a string containing the reason for the error
   Line           Returns a long integer representing the line
                   number for the error
   Linepos        Returns a long integer representing the line
                   position for the error
   srcText        Returns a string containing the line that caused the
                   error
   url            Returns the URL pointing the loaded document
   Filepos        Returns a long integer file position of the error
THANK YOU !!

More Related Content

What's hot (20)

PDF
Modular Programming in C
bhawna kol
 
PDF
Command line-arguments-in-java-tutorial
Kuntal Bhowmick
 
PPTX
Triggers
Pooja Dixit
 
PPT
Introduction to XML
yht4ever
 
PPTX
Operating system paging and segmentation
hamza haseeb
 
PPT
Class and object in C++
rprajat007
 
PPT
03 namespace
Baskarkncet
 
PPTX
XSLT
Kamal Acharya
 
PPTX
Normal forms
Samuel Igbanogu
 
PPTX
Generalization and specialization
Knowledge Center Computer
 
PPTX
It8074 soa-unit i
RevathiAPICSE
 
PPTX
Components of .NET Framework
Roshith S Pai
 
ODP
HTML5
Hatem Mahmoud
 
PPTX
Unit 4 plsql
DrkhanchanaR
 
PPT
Bottom - Up Parsing
kunj desai
 
PPT
Introduction to data structures and Algorithm
Dhaval Kaneria
 
PPTX
Memory management ppt
ManishaJha43
 
PDF
Triggers and active database
BalaMuruganSamuthira
 
PDF
HTML and XML Difference FAQs
Umar Ali
 
PPTX
Dbms architecture
Shubham Dwivedi
 
Modular Programming in C
bhawna kol
 
Command line-arguments-in-java-tutorial
Kuntal Bhowmick
 
Triggers
Pooja Dixit
 
Introduction to XML
yht4ever
 
Operating system paging and segmentation
hamza haseeb
 
Class and object in C++
rprajat007
 
03 namespace
Baskarkncet
 
Normal forms
Samuel Igbanogu
 
Generalization and specialization
Knowledge Center Computer
 
It8074 soa-unit i
RevathiAPICSE
 
Components of .NET Framework
Roshith S Pai
 
Unit 4 plsql
DrkhanchanaR
 
Bottom - Up Parsing
kunj desai
 
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Memory management ppt
ManishaJha43
 
Triggers and active database
BalaMuruganSamuthira
 
HTML and XML Difference FAQs
Umar Ali
 
Dbms architecture
Shubham Dwivedi
 

Viewers also liked (20)

PPTX
An Introduction to the DOM
Mindy McAdams
 
PPT
XML and XPath details
DSK Chakravarthy
 
PPTX
Dom
Surinder Kaur
 
PPT
Xpath presentation
Alfonso Gabriel López Ceballos
 
PPT
Xpath
Manav Prasad
 
PPTX
Document object model
Amit kumar
 
PDF
Xml parsing
Malintha Adikari
 
PPT
XPath - XML Path Language
yht4ever
 
PPTX
XSLT
Surinder Kaur
 
PDF
Parsing XML Data
Mu Chun Wang
 
PPTX
Overview of XSL, XPath and XSL-FO
Suite Solutions
 
PPTX
Document Object Model
Mayur Mudgal
 
PDF
XML DOM
Hoang Nguyen
 
PPT
Java XML Parsing
srinivasanjayakumar
 
PPTX
XSLT
rpoplai
 
PPT
Document Object Model
chomas kandar
 
PPT
XML/XSLT
thinkahead.net
 
PPT
Introduction to XML
Jussi Pohjolainen
 
PPT
DOM and SAX
Jussi Pohjolainen
 
An Introduction to the DOM
Mindy McAdams
 
XML and XPath details
DSK Chakravarthy
 
Document object model
Amit kumar
 
Xml parsing
Malintha Adikari
 
XPath - XML Path Language
yht4ever
 
Parsing XML Data
Mu Chun Wang
 
Overview of XSL, XPath and XSL-FO
Suite Solutions
 
Document Object Model
Mayur Mudgal
 
XML DOM
Hoang Nguyen
 
Java XML Parsing
srinivasanjayakumar
 
XSLT
rpoplai
 
Document Object Model
chomas kandar
 
XML/XSLT
thinkahead.net
 
Introduction to XML
Jussi Pohjolainen
 
DOM and SAX
Jussi Pohjolainen
 
Ad

Similar to Understanding XML DOM (20)

PPT
Xml nisha dwivedi
NIIT
 
PPT
Xml 215-presentation
Simsima Tchakma
 
PPTX
Chapter 18
application developer
 
PPTX
Part 7
NOHA AW
 
PPTX
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Ayes Chinmay
 
PDF
Unit 10: XML and Beyond (Sematic Web, Web Services, ...)
DSBW 2011/2002 - Carles Farré - Barcelona Tech
 
PPTX
Xml writers
Raghu nath
 
PPTX
Unit 2
team11vgnt
 
PPTX
Xml session
Farag Zakaria
 
PPTX
java API for XML DOM
Surinder Kaur
 
PPTX
The xml
Raghu nath
 
PPT
[DSBW Spring 2010] Unit 10: XML and Web And beyond
Carles Farré
 
PPTX
Unit-2_XMxvvxvxvxvLccccccccccccccccccccccccccc.pptx
VikasTuwar1
 
PDF
Ch23 xml processing_with_java
ardnetij
 
PDF
Ch23
preetamju
 
PPTX
advDBMS_XML.pptx
IreneGetzi
 
PPT
DOM Quick Overview
Signure Technologies
 
PPTX
06 xml processing-in-.net
glubox
 
Xml nisha dwivedi
NIIT
 
Xml 215-presentation
Simsima Tchakma
 
Part 7
NOHA AW
 
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Ayes Chinmay
 
Unit 10: XML and Beyond (Sematic Web, Web Services, ...)
DSBW 2011/2002 - Carles Farré - Barcelona Tech
 
Xml writers
Raghu nath
 
Unit 2
team11vgnt
 
Xml session
Farag Zakaria
 
java API for XML DOM
Surinder Kaur
 
The xml
Raghu nath
 
[DSBW Spring 2010] Unit 10: XML and Web And beyond
Carles Farré
 
Unit-2_XMxvvxvxvxvLccccccccccccccccccccccccccc.pptx
VikasTuwar1
 
Ch23 xml processing_with_java
ardnetij
 
Ch23
preetamju
 
advDBMS_XML.pptx
IreneGetzi
 
DOM Quick Overview
Signure Technologies
 
06 xml processing-in-.net
glubox
 
Ad

More from Om Vikram Thapa (20)

PDF
Next Set of Leaders Series
Om Vikram Thapa
 
PDF
Integration Testing at go-mmt
Om Vikram Thapa
 
PDF
Understanding payments
Om Vikram Thapa
 
PDF
System Alerting & Monitoring
Om Vikram Thapa
 
PDF
Serverless computing
Om Vikram Thapa
 
PDF
Sumologic Community
Om Vikram Thapa
 
PPTX
Postman Integration Testing
Om Vikram Thapa
 
PDF
Scalibility
Om Vikram Thapa
 
PDF
5 Dysfunctions of a team
Om Vikram Thapa
 
PDF
AWS Must Know
Om Vikram Thapa
 
PDF
Continuous Feedback
Om Vikram Thapa
 
PDF
Sql views, stored procedure, functions
Om Vikram Thapa
 
PDF
Confluence + jira together
Om Vikram Thapa
 
PDF
Understanding WhatFix
Om Vikram Thapa
 
PDF
Tech Recruitment Process
Om Vikram Thapa
 
PPTX
Jira Workshop
Om Vikram Thapa
 
PPT
Security@ecommerce
Om Vikram Thapa
 
PPT
Understanding iis part2
Om Vikram Thapa
 
PPT
Understanding iis part1
Om Vikram Thapa
 
PPT
.Net framework
Om Vikram Thapa
 
Next Set of Leaders Series
Om Vikram Thapa
 
Integration Testing at go-mmt
Om Vikram Thapa
 
Understanding payments
Om Vikram Thapa
 
System Alerting & Monitoring
Om Vikram Thapa
 
Serverless computing
Om Vikram Thapa
 
Sumologic Community
Om Vikram Thapa
 
Postman Integration Testing
Om Vikram Thapa
 
Scalibility
Om Vikram Thapa
 
5 Dysfunctions of a team
Om Vikram Thapa
 
AWS Must Know
Om Vikram Thapa
 
Continuous Feedback
Om Vikram Thapa
 
Sql views, stored procedure, functions
Om Vikram Thapa
 
Confluence + jira together
Om Vikram Thapa
 
Understanding WhatFix
Om Vikram Thapa
 
Tech Recruitment Process
Om Vikram Thapa
 
Jira Workshop
Om Vikram Thapa
 
Security@ecommerce
Om Vikram Thapa
 
Understanding iis part2
Om Vikram Thapa
 
Understanding iis part1
Om Vikram Thapa
 
.Net framework
Om Vikram Thapa
 

Recently uploaded (20)

PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Python basic programing language for automation
DanialHabibi2
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 

Understanding XML DOM

  • 1. Understanding XML DOM (W3C Standard) Created by : Om Vikram Thapa
  • 2. INDEX :  XML DOM – Introduction  DOM Nodes (Tree Structure)  DOM Parsing  DOM Load Functions (in IE & FireFox)  DOM Properties & Methods  DOM HttpRequest  DOM Node Types  DOM Parse Error Objects  Thank You!!
  • 3. XML DOM (INTRODUCTION)  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM is a W3C (World Wide Web Consortium) standard.  DOM defines the objects and properties and methods (interface) to access all XML elements.  The DOM presents an XML document as a tree structure, with elements, attributes, and text as nodes.  The DOM 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
  • 4. What is an XML DOM?  The XML DOM is: - A standard object model for XML - A standard programming interface for XML - Platform and language-independent - A W3C standard  The XML DOM defines the objects and properties of all XML elements, and the methods (interface) to access them.  The XML DOM is a standard for how to get, change, add or delete XML elements.
  • 5. AN EXAMPLE OF books.xml: <bookstore> - <book category="cooking"> <title lang="en">Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> - <book category="language"> <title lang="en">English</title> <author>Om Vikram</author> <year>2005</year> <price>50.00</price> </book> </bookstore>
  • 7. DOM NODES DESCRIPTION  According to the DOM, everything in an XML document is a node.  The entire document is a document node .  Every XML element is an element node .  The text in the XML elements are text nodes .  Every attribute is an attribute node .  Comments are comment nodes. In our ex. - The root node <bookstore> holds four <book> nodes. - Each <book> node contain 4 text node i.e. <title>, <author>, <year>, and <price>
  • 8. XML DOM PARSING:  Most browsers have a build-in XML parser to read and manipulate XML.  The parser reads XML into memory and converts XML it into XML DOM object which is accessible from JavaScript .  There are some differences between Microsoft's XML parser and the parsers used in other browsers.  The MS parser supports loading of both XML files and XML strings (text)  Other browsers use Separate parsers.  However, all parsers contain functions to traverse XML trees, access, insert, and delete nodes.
  • 9. Loading XML with IE using MS XML Parser:  The following JavaScript fragment loads an XML document “book.xml” into the parser : xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.load("books.xml");  The following JavaScript fragment loads an XML text into the parser : xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(txt);
  • 10. Loading XML with FireFox & Other XML Parser :  The following JavaScript fragment loads an XML document “book.xml” into the parser : xmlDoc=document.implementation.createDocument("","",null) ; xmlDoc.async="false"; xmlDoc.load("books.xml");  The following JavaScript fragment loads an XML text into the parser : parser=new DOMParser(); xmlDoc=parser.parseFromString(txt,"text/xml");
  • 11. DOM PROPERTIES & METHODS:  XML DOM Properties:  x.nodeName - the name of x  x.nodeValue - the value of x  x.parentNode - the parent node of x  x.childNodes - the child nodes of x  x.attributes - the attributes nodes of x (where x is a node object. )  XML DOM Methods:  x.getElementsByTagName(name) - get all elements with a specified tag name  x.appendChild(node) - insert a child node to x  x.removeChild(node) - remove a child node from x
  • 12. AN EXAMPLE : txt=xmlObj.getElementsByTagName("title")[0].childNodes[0].nodeValue; where  xmlObj - the XML DOM object created by the parser.  getElementsByTagName("title")[0] - the first <title> element  childNodes[0] - the first child of the <title> element (the text node)  nodeValue - the value of the node (the text itself)
  • 13. NODE TYPES NodeTypes Named Constants  1 ELEMENT_NODE  2 ATTRIBUTE_NODE  3 TEXT_NODE  4 CDATA_SECTION_NODE  5 ENTITY_REFERENCE_NODE  6 ENTITY_NODE  7 PROCESSING_INSTRUCTION_NODE  8 COMMENT_NODE  9 DOCUMENT_NODE  10 DOCUMENT_TYPE_NODE  11 DOCUMENT_FRAGMENT_NODE  12 NOTATION_NODE
  • 14. DOM PARSE ERROR OBJECTS  When trying to open an XML document, a parser-error may occur.  With the parseError object, you can retrieve the error code, the error text, the line that caused the error, and more. Property Description  errorCode Returns a long integer error code  Reason Returns a string containing the reason for the error  Line Returns a long integer representing the line number for the error  Linepos Returns a long integer representing the line position for the error  srcText Returns a string containing the line that caused the error  url Returns the URL pointing the loaded document  Filepos Returns a long integer file position of the error