Class 11 Notes for XML

Learning Objectives:

You will be able to describe how HTML and XML works together.

You will be able to describe how JavaScript or PHP use DOM to change an XML document..

Homework:

Read the HTML DOM, XML DOM and JavaScript tutorials from the W3schools.

Read: Chapter 9

What is JavaScript:

JavaScript is an event driven Language that is quasi Object Oriented Language. (A very cool example of Javascript and HTML working together.)

Javascript can use Objects, Methods (built-in functions), Properties (characteristics) and Functions to manipulate HTML, XML, and PHP.

JavaScript will be the tool we will use to manipulate XML and HTML documents.

 

We will be using two Functions to access HTML and XML Documents:

HTML Dom

 

 

HTML DOM favorite way to access an element is getElementById("ID")

 

XML DOM favorite way to access an element is getElementsByTagName("tagName")

 

 

 

 

 

 

 

Start the Final Project

 

Topics Covered:

 

 

Online JavaScript Tutorials

The W3schools is a great resource for HTML and JavaScript

Code Academy also has great tutorials for HTML and JavaScript

 

Document Object Model (DOM):

The Document Object Model is a programming interface for XML and HTML documents.
The DOM defines the way an HTML and XML documents can be accessed and manipulated using PHP or JavaScript.

DOM breaks an HTML and XML into parts that can be changed using a scripting language like.

An XML Parser uses DOM to break the XML document into an object Tree (based on the DOM core). The tree is loaded into the computer's memory so you can manipulate the objects using an object oriented language.

 

 

Example of DOM in action:

Loading Schedule.XML into memory using Javascript:

<script type="text/javascript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("schedule.xml") document.write
("Show Me the node: ")

document.write
(xmlDoc.documentElement.childNodes.item(0).text)
</script>

Try it with (xmlDoc.documentElement.nodeName) or (xmlDoc.documentElement.getAttribute("time"))

Terms:

Parser, DOM, Javascript, Method, Properties, Functions, Object Oriented Programming

 

 

Final Step:

Review in your mind everything we covered in class and remember to cover it again before you go to bed so your mind to process this information while you sleep.