Note 12 for XML
Watch & Read:
Example: 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>Show me the Node
Try it with (xmlDoc.documentElement.nodeName) or (xmlDoc.documentElement.getAttribute("time"))
Syntax for VB Script, Java Script and ASP:
Java Script: var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
VBScript: set xmlDoc = CreateObject("Microsoft.XMLDOM")
Active Server Page (using VB Script): set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
Example: XML, XSL & Javascript Combined
Example of HTML that uses XML, CSS and Javascript (Setup for IE only)
AJAX is the marriage between JavaScript, CSS (or XSL) and XML
Wikipedia AJAX & AJAX HTML Controls
In the DOM, everything is a node. Element nodes does not have a text value.
The text of an element node is stored in a child node. This node is called a text node.
SAX & DOM provide a method for accessing and manipulating every object within an XML Document
Simple API for XML (Mini version of DOM)
SAX is similar to DOM except in the method of loading the XML object tree into memory. DOM loads the complete document and SAX loads the XML document one element at a time. (Better use of memory for large XML documents)
Document Object Model
W3schools said it best: The XML Document Object Model is a programming interface for XML documents.
The DOM defines the way an XML document can be accessed and manipulated.DOM is an evolving API. Cover has a good background and explanation of DOM
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.
We will be using Microsoft XML Parser (built into IE 7)
DOM & XPath will allow you to select nodes deep within your XML document: SelectSingleNode("Xpath") Example to manipulate the Title Element in schedule.xml: SelectSingleNode("/FallSchedule/Class/Title")
Review the following:
HTML DOM on W3schools
XML DOM on W3schools
JavaScript on W3schools
Terms you need to Lookup:
SAX, DOM, Javascript, method, properties, Object Oriented Programming
Homework:
Read pg 465-482 of your book!
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.