SlideShare a Scribd company logo
1 of 17
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)

Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Xhtml
XhtmlXhtml
Xhtml
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
 
Introduction to XHTML
Introduction to XHTMLIntroduction to XHTML
Introduction to XHTML
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
 
Understanding XML DOM
Understanding XML DOMUnderstanding XML DOM
Understanding XML DOM
 
Xml ppt
Xml pptXml ppt
Xml ppt
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Java Beans
Java BeansJava Beans
Java Beans
 
Java script
Java scriptJava script
Java script
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Html
HtmlHtml
Html
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 

Similar to XML Document Object Model (DOM)

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

Part 7
Part 7Part 7
Part 7
 
Unit iv xml dom
Unit iv xml domUnit iv xml dom
Unit iv xml dom
 
Xml dom
Xml domXml dom
Xml dom
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
 
JavaScript DOM & event
JavaScript DOM & eventJavaScript DOM & event
JavaScript DOM & event
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Xml
XmlXml
Xml
 
HTML_DOM
HTML_DOMHTML_DOM
HTML_DOM
 
DOM Structure
DOM StructureDOM Structure
DOM Structure
 
DOM-XML
DOM-XMLDOM-XML
DOM-XML
 
Incremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend DevelopmentIncremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend Development
 
Dom
Dom Dom
Dom
 
RELAX NG to DTD and XSD Using the Open Toolkit
RELAX NG to DTD and XSD Using the Open ToolkitRELAX NG to DTD and XSD Using the Open Toolkit
RELAX NG to DTD and XSD Using the Open Toolkit
 
Building XML Based Applications
Building XML Based ApplicationsBuilding XML Based Applications
Building XML Based Applications
 
INFT132 093 07 Document Object Model
INFT132 093 07 Document Object ModelINFT132 093 07 Document Object Model
INFT132 093 07 Document Object Model
 
lect9
lect9lect9
lect9
 
lect9
lect9lect9
lect9
 
INFT132 093 04 HTML and XHTML
INFT132 093 04 HTML and XHTMLINFT132 093 04 HTML and XHTML
INFT132 093 04 HTML and XHTML
 
buildingxmlbasedapplications-180322042009.pptx
buildingxmlbasedapplications-180322042009.pptxbuildingxmlbasedapplications-180322042009.pptx
buildingxmlbasedapplications-180322042009.pptx
 

More from BOSS Webtech

JavaScript Object Notation (JSON)
JavaScript Object Notation (JSON)JavaScript Object Notation (JSON)
JavaScript Object Notation (JSON)BOSS Webtech
 
AdNet :: Banner and Ad management software
AdNet :: Banner and Ad management softwareAdNet :: Banner and Ad management software
AdNet :: Banner and Ad management softwareBOSS Webtech
 
Common Mistakes Made By Web Developers
Common Mistakes Made By Web DevelopersCommon Mistakes Made By Web Developers
Common Mistakes Made By Web DevelopersBOSS Webtech
 
How to do better Quality Assurance for Cross-Browser Testing
How to do better Quality Assurance for Cross-Browser TestingHow to do better Quality Assurance for Cross-Browser Testing
How to do better Quality Assurance for Cross-Browser TestingBOSS Webtech
 

More from BOSS Webtech (7)

JavaScript Object Notation (JSON)
JavaScript Object Notation (JSON)JavaScript Object Notation (JSON)
JavaScript Object Notation (JSON)
 
Cluster Computing
Cluster ComputingCluster Computing
Cluster Computing
 
AdNet :: Banner and Ad management software
AdNet :: Banner and Ad management softwareAdNet :: Banner and Ad management software
AdNet :: Banner and Ad management software
 
Security Testing
Security TestingSecurity Testing
Security Testing
 
M-Commerce
M-CommerceM-Commerce
M-Commerce
 
Common Mistakes Made By Web Developers
Common Mistakes Made By Web DevelopersCommon Mistakes Made By Web Developers
Common Mistakes Made By Web Developers
 
How to do better Quality Assurance for Cross-Browser Testing
How to do better Quality Assurance for Cross-Browser TestingHow to do better Quality Assurance for Cross-Browser Testing
How to do better Quality Assurance for Cross-Browser Testing
 

Recently uploaded

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

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 info@bosswebtech.com