SlideShare a Scribd company logo
3
Most read
4
Most read
5
Most read
XML DOM

 Prepared by: Pawan Dhawan
     Software Engineer
        Jan -30-2012
BOSS Webtech Private Limited
   www.bosswebtech.com
Points we will covered

•   What is XML DOM .
•   Its structure.
•   Its advantages and disadvantages
•   Its uses.
WHAT IS DOM ?
• DOM is the Document Object Model.
• The DOM is a W3C (World Wide Web
  Consortium) standard.
• The DOM defines a standard for accessing
  documents like XML and HTML:
• DOM is memory-based, this making it
  traversable and editable.
• DOM is not language-specific, nor is it
  platform-specific.
What is the 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
DOM Nodes

According to the DOM, everything in an XML
  document is a node.
The DOM says:
• 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
DOM Example
<?xml version="1.0" encoding="ISO-8859-1"?>
  <bookstore>
       <book category="cooking">
              <title lang="en">Everyday Italian</title>
              <author>Giada De Laurentiis</author>
              <year>2005</year>
              <price>30.00</price>
       </book>
       <book category="web" cover="paperback">
              <title lang="en">Learning XML</title>
              <author>Erik T. Ray</author>
              <year>2003</year>
              <price>39.95</price>
       </book>
  </bookstore>
The XML DOM Node Tree
XML DOM Properties

These are some typical 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

Note: In the list above, 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

Note: In the list above, x is a node object.
Example
txt=xmlDoc.getElementsByTagName("title")[0].c
  hildNodes[0].nodeValue
• xmlDoc - the XML DOM object .
• 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)
Traversing the Node Tree
<html>
   <head>
        <script type="text/javascript" src="loadxmlstring.js"></script>
   </head>
   <body>
        <script type="text/javascript">
                  text="<book>";
                  text=text+"<title>Everyday Italian</title>";
                  text=text+"<author>Giada De Laurentiis</author>";
                  text=text+"<year>2005</year>";
                  text=text+"</book>";
                    xmlDoc=loadXMLString(text);
                    // documentElement always represents the root node
                    x=xmlDoc.documentElement.childNodes;
                    for (i=0;i<x.length;i++)
                    {
                               document.write(x[i].nodeName);
                               document.write(": ");
                               document.write(x[i].childNodes[0].nodeValue);
                               document.write("<br />");
                    }
        </script>
   </body>
</html>
Out Put
title: Everyday Italian
author: Giada De Laurentiis
year: 2005
Advantages of XML DOM
• XML structure is traversable.
  Each node can be randomly accessed (one or
  more times) by traversing the tree.
• XML structure is modifiable.
  Since the XML structure is resident in memory,
  values can be added, changed, and removed.
• The DOM standard is maintained by the World
  Wide Web Consortium.
Disadvantages of XML DOM
• Resource intensive
  Since the XML structure is resident in memory,
  the larger the XML structure is, the more
  memory it will consume.
• Relative speed
  In comparison to SAX, DOM can be much
  slower due to its resource usage/ needs.
Uses of XML DOM
• The XML DOM defines a standard way for
  accessing and manipulating XML documents.
• The DOM presents an XML document as a
  tree-structure.
• Knowing the XML DOM makes working easier
  with XML.
ThankYou!!
About BOSS Webtech
o   BOSS Webtech is a process oriented design house specializing in web design,
    web development, backend web programming, mobile application
    development and other web and mobile related design and support services.

o   Recently launched BizPlus – Mobile based survey software. Check it more
    here http://bizplusonline.com/

o   More products here http://www.bosswebtech.com/products/products.html

    Contact BOSS Webtech
o   Call 831-998-9121 at US EST/CST/MST/PST Zone
    or email info@bosswebtech.com

More Related Content

What's hot (20)

PPT
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
PPTX
Xml presentation
Miguel Angel Teheran Garcia
 
PPT
XML Schema
yht4ever
 
PPTX
Complete Lecture on Css presentation
Salman Memon
 
PDF
Html text and formatting
eShikshak
 
PPT
Document Object Model
chomas kandar
 
PDF
Html frames
eShikshak
 
PPTX
HTML5 audio & video
Hamza Zahid
 
PPTX
HTTP request and response
Sahil Agarwal
 
PPTX
Php string function
Ravi Bhadauria
 
PPT
Jsp ppt
Vikas Jagtap
 
PPT
Xml parsers
Manav Prasad
 
PPTX
DTD
Kamal Acharya
 
PPT
02 xml schema
Baskarkncet
 
PPTX
Web html table tags
Kainat Ilyas
 
PPTX
Event In JavaScript
ShahDhruv21
 
PPTX
Static and Dynamic webpage
Aishwarya Pallai
 
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
Xml presentation
Miguel Angel Teheran Garcia
 
XML Schema
yht4ever
 
Complete Lecture on Css presentation
Salman Memon
 
Html text and formatting
eShikshak
 
Document Object Model
chomas kandar
 
Html frames
eShikshak
 
HTML5 audio & video
Hamza Zahid
 
HTTP request and response
Sahil Agarwal
 
Php string function
Ravi Bhadauria
 
Jsp ppt
Vikas Jagtap
 
Xml parsers
Manav Prasad
 
02 xml schema
Baskarkncet
 
Web html table tags
Kainat Ilyas
 
Event In JavaScript
ShahDhruv21
 
Static and Dynamic webpage
Aishwarya Pallai
 

Similar to XML Document Object Model (DOM) (20)

PPTX
Part 7
NOHA AW
 
PPTX
Unit iv xml dom
smitha273566
 
PPT
Understanding XML DOM
Om Vikram Thapa
 
PPTX
Xml dom
sana mateen
 
PDF
Jdom how it works & how it opened the java process
Hicham QAISSI
 
PDF
JavaScript DOM & event
Borey Lim
 
PPT
Document Object Model
chomas kandar
 
PDF
HTML_DOM
BIT DURG
 
PDF
Incremental DOM and Recent Trend of Frontend Development
Akihiro Ikezoe
 
PPTX
Dom
Surinder Kaur
 
PPTX
RELAX NG to DTD and XSD Using the Open Toolkit
Contrext Solutions
 
PDF
Building XML Based Applications
Prabu U
 
PPTX
INFT132 093 07 Document Object Model
Michael Rees
 
PDF
lect9
tutorialsruby
 
PDF
lect9
tutorialsruby
 
PPTX
INFT132 093 04 HTML and XHTML
Michael Rees
 
PPTX
Document Object Model (DOM)
GOPAL BASAK
 
Part 7
NOHA AW
 
Unit iv xml dom
smitha273566
 
Understanding XML DOM
Om Vikram Thapa
 
Xml dom
sana mateen
 
Jdom how it works & how it opened the java process
Hicham QAISSI
 
JavaScript DOM & event
Borey Lim
 
Document Object Model
chomas kandar
 
HTML_DOM
BIT DURG
 
Incremental DOM and Recent Trend of Frontend Development
Akihiro Ikezoe
 
RELAX NG to DTD and XSD Using the Open Toolkit
Contrext Solutions
 
Building XML Based Applications
Prabu U
 
INFT132 093 07 Document Object Model
Michael Rees
 
INFT132 093 04 HTML and XHTML
Michael Rees
 
Document Object Model (DOM)
GOPAL BASAK
 
Ad

More from BOSS Webtech (7)

PPT
JavaScript Object Notation (JSON)
BOSS Webtech
 
PPT
Cluster Computing
BOSS Webtech
 
PPT
AdNet :: Banner and Ad management software
BOSS Webtech
 
PPTX
Security Testing
BOSS Webtech
 
PPT
M-Commerce
BOSS Webtech
 
PPT
Common Mistakes Made By Web Developers
BOSS Webtech
 
PPT
How to do better Quality Assurance for Cross-Browser Testing
BOSS Webtech
 
JavaScript Object Notation (JSON)
BOSS Webtech
 
Cluster Computing
BOSS Webtech
 
AdNet :: Banner and Ad management software
BOSS Webtech
 
Security Testing
BOSS Webtech
 
M-Commerce
BOSS Webtech
 
Common Mistakes Made By Web Developers
BOSS Webtech
 
How to do better Quality Assurance for Cross-Browser Testing
BOSS Webtech
 
Ad

Recently uploaded (20)

PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PPTX
PCU Keynote at IEEE World Congress on Services 250710.pptx
Ramesh Jain
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PDF
Basics of Electronics for IOT(actuators ,microcontroller etc..)
arnavmanesh
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PDF
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PPTX
Using Google Data Studio (Looker Studio) to Create Effective and Easy Data Re...
Orage Technologies
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PCU Keynote at IEEE World Congress on Services 250710.pptx
Ramesh Jain
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
Basics of Electronics for IOT(actuators ,microcontroller etc..)
arnavmanesh
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Using Google Data Studio (Looker Studio) to Create Effective and Easy Data Re...
Orage Technologies
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 

XML Document Object Model (DOM)

  • 1. XML DOM Prepared by: Pawan Dhawan Software Engineer Jan -30-2012 BOSS Webtech Private Limited www.bosswebtech.com
  • 2. Points we will covered • What is XML DOM . • Its structure. • Its advantages and disadvantages • Its uses.
  • 3. WHAT IS DOM ? • DOM is the Document Object Model. • The DOM is a W3C (World Wide Web Consortium) standard. • The DOM defines a standard for accessing documents like XML and HTML: • DOM is memory-based, this making it traversable and editable. • DOM is not language-specific, nor is it platform-specific.
  • 4. What is the 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
  • 5. DOM Nodes According to the DOM, everything in an XML document is a node. The DOM says: • 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
  • 6. DOM Example <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="web" cover="paperback"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>
  • 7. The XML DOM Node Tree
  • 8. XML DOM Properties These are some typical 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 Note: In the list above, x is a node object.
  • 9. 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 Note: In the list above, x is a node object.
  • 10. Example txt=xmlDoc.getElementsByTagName("title")[0].c hildNodes[0].nodeValue • xmlDoc - the XML DOM object . • 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)
  • 11. Traversing the Node Tree <html> <head> <script type="text/javascript" src="loadxmlstring.js"></script> </head> <body> <script type="text/javascript"> text="<book>"; text=text+"<title>Everyday Italian</title>"; text=text+"<author>Giada De Laurentiis</author>"; text=text+"<year>2005</year>"; text=text+"</book>"; xmlDoc=loadXMLString(text); // documentElement always represents the root node x=xmlDoc.documentElement.childNodes; for (i=0;i<x.length;i++) { document.write(x[i].nodeName); document.write(": "); document.write(x[i].childNodes[0].nodeValue); document.write("<br />"); } </script> </body> </html>
  • 12. Out Put title: Everyday Italian author: Giada De Laurentiis year: 2005
  • 13. Advantages of XML DOM • XML structure is traversable. Each node can be randomly accessed (one or more times) by traversing the tree. • XML structure is modifiable. Since the XML structure is resident in memory, values can be added, changed, and removed. • The DOM standard is maintained by the World Wide Web Consortium.
  • 14. Disadvantages of XML DOM • Resource intensive Since the XML structure is resident in memory, the larger the XML structure is, the more memory it will consume. • Relative speed In comparison to SAX, DOM can be much slower due to its resource usage/ needs.
  • 15. Uses of XML DOM • The XML DOM defines a standard way for accessing and manipulating XML documents. • The DOM presents an XML document as a tree-structure. • Knowing the XML DOM makes working easier with XML.
  • 17. About BOSS Webtech o BOSS Webtech is a process oriented design house specializing in web design, web development, backend web programming, mobile application development and other web and mobile related design and support services. o Recently launched BizPlus – Mobile based survey software. Check it more here http://bizplusonline.com/ o More products here http://www.bosswebtech.com/products/products.html Contact BOSS Webtech o Call 831-998-9121 at US EST/CST/MST/PST Zone or email [email protected]