SlideShare a Scribd company logo
1 of 14
Document Object
Model(DOM)
Tharaa Abu Ashour
tharaa_1993@yahoo.com
Outline:
How Browser Works?
What is the DOM?
What is the Node?
The DOM structure Model.
Example of DOM
How Can Access the Nodes?
Adding Text Node to the Page
Advantages and Disadvantages.
Browser Components:
How Browser Works?
Source code (plain text) will be parsed into DOM tree.
With DOM tree will parse the content on the screen accordingly (css,
javascript...)
DOM tree is a data represented in tree structure.
Source
Code
DOM
Parser
DOM
Tree
Render
Engine
Web
Page
What is the DOM?
Document Object Model is a platform and language neutral
interface that allow program and script to dynamically
access and update the content, structure and style of
document.
The DOM is an application programming interface (API) for
HTML and XML documents.
DOM is being developed by W3C, lets the programmer to
access, modify HTML pages and XML docments.
What is the Node?
•DOM is a tree of nodes of various types.
•Nodes
Text Node Attribute Node
Element Node
The DOM Structure Model
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Heading 1</h1>
<p>Paragraph </p>
<h2>Heading 2</h2>
<p>Heading 1</p>
</body>
</html>
HTML
bodyhead
title
Hello World
H1 P H2 P
Heading 1 Heading 2Paragraph Paragraph
DOM Tree Visualizer: https://gojs.net/latest/samples/DOMTree.html
#document
Child, Sibling, Parent
body
H1 P H2 P
#text #text #text #text
Last child
Firstchild
Firstchild
Firstchild
Firstchild
previousSibling
NextSibling
previousSibling
NextSibling
previousSibling
NextSibling
parentNode
parentNode
parentNode
parentNode
Child, Sibling, Parent
body
H1 P H2 P
#text #text #text #text
So, How can access the text in
Header2?!
Firstchild
nextSibling nextSibling
Firstchild
How can access the nodes?
By their name or Id (it will allow you to work with one element, and it's the
easiest way)
GetElementByName(NodeName)
GetEllemtById(IdName)
By Tag Name (GetElementsByTagName), it will return array of nodes
By their relation to parent, child, sibling
(nextSibling,previousSibling,parentNode,lastchild, firstchild, childNode) , childNode[0] ==
first child
Adding text Node to the Page
Create New Node
-var newNode = document.createElement("p");
Create Text Node
-var textNode = document.createTextNode("hello world");
Link Text Node with New Node
-NewNode.appendChild(textNod);
Link Node to the DOM tree -Document.getElementById("id").appendChild(newNode)
Advantages and Disadvantages of DOM
Advantages:
Robust API for the DOM tree
Easy to modify the data structure and extract data.
Can be written with any language
Disadvantages:
Store the entire document in the memory.
Based on DOM can written with any language, method naming convention don't
follow standard java programming convension
Questions?
Thank You :)

More Related Content

What's hot

New Elements & Features in HTML5
New Elements & Features in HTML5New Elements & Features in HTML5
New Elements & Features in HTML5Jamshid Hashimi
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object ModelWebStackAcademy
 
Intro to HTML & CSS
Intro to HTML & CSSIntro to HTML & CSS
Intro to HTML & CSSSyed Sami
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)GOPAL BASAK
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overviewJacob Nelson
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designersSingsys Pte Ltd
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3Doris Chen
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)Partnered Health
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptFahim Abdullah
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSSAmit Tyagi
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOMMindy McAdams
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controlsRaed Aldahdooh
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - ObjectsWebStackAcademy
 

What's hot (20)

New Elements & Features in HTML5
New Elements & Features in HTML5New Elements & Features in HTML5
New Elements & Features in HTML5
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Intro to HTML & CSS
Intro to HTML & CSSIntro to HTML & CSS
Intro to HTML & CSS
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
 
Html n CSS
Html n CSSHtml n CSS
Html n CSS
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
Basic Details of HTML and CSS.pdf
Basic Details of HTML and CSS.pdfBasic Details of HTML and CSS.pdf
Basic Details of HTML and CSS.pdf
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
 
Css
CssCss
Css
 
CSS
CSSCSS
CSS
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 

Viewers also liked

DOM Features You Didn’t Know Existed
DOM Features You Didn’t Know ExistedDOM Features You Didn’t Know Existed
DOM Features You Didn’t Know ExistedFITC
 
JavaScript DOM Manipulations
JavaScript DOM ManipulationsJavaScript DOM Manipulations
JavaScript DOM ManipulationsYnon Perek
 
INTRODUCTION TO DOM AND DOM TREE
INTRODUCTION TO DOM AND DOM TREEINTRODUCTION TO DOM AND DOM TREE
INTRODUCTION TO DOM AND DOM TREEsystematiclab
 
Browser Object Model and Animations in qooxdoo
Browser Object Model and Animations in qooxdooBrowser Object Model and Animations in qooxdoo
Browser Object Model and Animations in qooxdooSebastian Werner
 
Browser Object Model
Browser Object ModelBrowser Object Model
Browser Object Modeljay li
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
14. session 14 dhtml filter
14. session 14   dhtml filter14. session 14   dhtml filter
14. session 14 dhtml filterPhúc Đỗ
 
Javascript basics
Javascript basicsJavascript basics
Javascript basicsSolv AS
 
Working with Arrays in JavaScript
Working with Arrays in JavaScriptWorking with Arrays in JavaScript
Working with Arrays in JavaScriptFlorence Davis
 
Javascript - Array - Writing
Javascript - Array - WritingJavascript - Array - Writing
Javascript - Array - WritingSamuel Santos
 
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...Valeri Karpov
 
Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)
Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)
Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)Shreeraj Shah
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developersKai Koenig
 
Gost r 53909 2010
Gost r 53909 2010Gost r 53909 2010
Gost r 53909 2010Raphael254
 
Mental  Health  program
Mental  Health  programMental  Health  program
Mental  Health  programbcole13
 
Презентація:Математичне лото (додавання звичайних дробів)
Презентація:Математичне лото (додавання звичайних дробів)Презентація:Математичне лото (додавання звичайних дробів)
Презентація:Математичне лото (додавання звичайних дробів)sveta7940
 
Tarea 5. controladores antonio rodriguez
Tarea 5. controladores    antonio rodriguezTarea 5. controladores    antonio rodriguez
Tarea 5. controladores antonio rodriguezlicett lopez
 

Viewers also liked (20)

DOM Features You Didn’t Know Existed
DOM Features You Didn’t Know ExistedDOM Features You Didn’t Know Existed
DOM Features You Didn’t Know Existed
 
JavaScript DOM Manipulations
JavaScript DOM ManipulationsJavaScript DOM Manipulations
JavaScript DOM Manipulations
 
INTRODUCTION TO DOM AND DOM TREE
INTRODUCTION TO DOM AND DOM TREEINTRODUCTION TO DOM AND DOM TREE
INTRODUCTION TO DOM AND DOM TREE
 
Browser Object Model and Animations in qooxdoo
Browser Object Model and Animations in qooxdooBrowser Object Model and Animations in qooxdoo
Browser Object Model and Animations in qooxdoo
 
Browser Object Model
Browser Object ModelBrowser Object Model
Browser Object Model
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
14. session 14 dhtml filter
14. session 14   dhtml filter14. session 14   dhtml filter
14. session 14 dhtml filter
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Working with Arrays in JavaScript
Working with Arrays in JavaScriptWorking with Arrays in JavaScript
Working with Arrays in JavaScript
 
Javascript - Array - Writing
Javascript - Array - WritingJavascript - Array - Writing
Javascript - Array - Writing
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
 
Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)
Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)
Next Generation Web Attacks – HTML 5, DOM(L3) and XHR(L2)
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developers
 
Gost r 53909 2010
Gost r 53909 2010Gost r 53909 2010
Gost r 53909 2010
 
Mental  Health  program
Mental  Health  programMental  Health  program
Mental  Health  program
 
Презентація:Математичне лото (додавання звичайних дробів)
Презентація:Математичне лото (додавання звичайних дробів)Презентація:Математичне лото (додавання звичайних дробів)
Презентація:Математичне лото (додавання звичайних дробів)
 
Tarea 5. controladores antonio rodriguez
Tarea 5. controladores    antonio rodriguezTarea 5. controladores    antonio rodriguez
Tarea 5. controladores antonio rodriguez
 
Aporte Individual - MIRS
Aporte Individual - MIRSAporte Individual - MIRS
Aporte Individual - MIRS
 

Similar to Introduction to the DOM

Similar to Introduction to the DOM (20)

Dom
Dom Dom
Dom
 
Understanding the dom by Benedict Ayiko
Understanding the dom by Benedict AyikoUnderstanding the dom by Benedict Ayiko
Understanding the dom by Benedict Ayiko
 
DOM Quick Overview
DOM Quick OverviewDOM Quick Overview
DOM Quick Overview
 
Digital Marketing Company
Digital Marketing CompanyDigital Marketing Company
Digital Marketing Company
 
Understanding XML DOM
Understanding XML DOMUnderstanding XML DOM
Understanding XML DOM
 
Mongo learning series
Mongo learning series Mongo learning series
Mongo learning series
 
Web app development_html_01
Web app development_html_01Web app development_html_01
Web app development_html_01
 
Sperimentazioni di Tecnologie e Comunicazioni Multimediali: Lezione 3
Sperimentazioni di Tecnologie e Comunicazioni Multimediali: Lezione 3Sperimentazioni di Tecnologie e Comunicazioni Multimediali: Lezione 3
Sperimentazioni di Tecnologie e Comunicazioni Multimediali: Lezione 3
 
ITE212L Midterm Coverage
ITE212L Midterm CoverageITE212L Midterm Coverage
ITE212L Midterm Coverage
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
WEB DEVELOPMENT
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
HTML_CSS_JS Workshop
HTML_CSS_JS WorkshopHTML_CSS_JS Workshop
HTML_CSS_JS Workshop
 
Sweo talk
Sweo talkSweo talk
Sweo talk
 
Xml
XmlXml
Xml
 
The Language of the Web - HTML and CSS
The Language of the Web - HTML and CSSThe Language of the Web - HTML and CSS
The Language of the Web - HTML and CSS
 
WEB DEVELOPMENT
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 
Open source Technology
Open source TechnologyOpen source Technology
Open source Technology
 
Html tutorials-infotech aus
Html tutorials-infotech ausHtml tutorials-infotech aus
Html tutorials-infotech aus
 

Recently uploaded

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
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
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
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...
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Introduction to the DOM

  • 1. Document Object Model(DOM) Tharaa Abu Ashour tharaa_1993@yahoo.com
  • 2. Outline: How Browser Works? What is the DOM? What is the Node? The DOM structure Model. Example of DOM How Can Access the Nodes? Adding Text Node to the Page Advantages and Disadvantages.
  • 4. How Browser Works? Source code (plain text) will be parsed into DOM tree. With DOM tree will parse the content on the screen accordingly (css, javascript...) DOM tree is a data represented in tree structure. Source Code DOM Parser DOM Tree Render Engine Web Page
  • 5. What is the DOM? Document Object Model is a platform and language neutral interface that allow program and script to dynamically access and update the content, structure and style of document. The DOM is an application programming interface (API) for HTML and XML documents. DOM is being developed by W3C, lets the programmer to access, modify HTML pages and XML docments.
  • 6. What is the Node? •DOM is a tree of nodes of various types. •Nodes Text Node Attribute Node Element Node
  • 7. The DOM Structure Model <html> <head> <title>Hello World!</title> </head> <body> <h1>Heading 1</h1> <p>Paragraph </p> <h2>Heading 2</h2> <p>Heading 1</p> </body> </html> HTML bodyhead title Hello World H1 P H2 P Heading 1 Heading 2Paragraph Paragraph DOM Tree Visualizer: https://gojs.net/latest/samples/DOMTree.html #document
  • 8. Child, Sibling, Parent body H1 P H2 P #text #text #text #text Last child Firstchild Firstchild Firstchild Firstchild previousSibling NextSibling previousSibling NextSibling previousSibling NextSibling parentNode parentNode parentNode parentNode
  • 9. Child, Sibling, Parent body H1 P H2 P #text #text #text #text So, How can access the text in Header2?! Firstchild nextSibling nextSibling Firstchild
  • 10. How can access the nodes? By their name or Id (it will allow you to work with one element, and it's the easiest way) GetElementByName(NodeName) GetEllemtById(IdName) By Tag Name (GetElementsByTagName), it will return array of nodes By their relation to parent, child, sibling (nextSibling,previousSibling,parentNode,lastchild, firstchild, childNode) , childNode[0] == first child
  • 11. Adding text Node to the Page Create New Node -var newNode = document.createElement("p"); Create Text Node -var textNode = document.createTextNode("hello world"); Link Text Node with New Node -NewNode.appendChild(textNod); Link Node to the DOM tree -Document.getElementById("id").appendChild(newNode)
  • 12. Advantages and Disadvantages of DOM Advantages: Robust API for the DOM tree Easy to modify the data structure and extract data. Can be written with any language Disadvantages: Store the entire document in the memory. Based on DOM can written with any language, method naming convention don't follow standard java programming convension

Editor's Notes

  1. 1
  2. 2
  3. 4
  4. 5
  5. 6
  6. 7
  7. 8
  8. 9
  9. 10
  10. 11
  11. 12
  12. 14