Académique Documents
Professionnel Documents
Culture Documents
Programming
XML Processing
Contents
Markup
XML
DTDs
XML Parsers
DOM
Markup
Smith
123 Main St.
Toronto
Ontario
Markup
Markup is added to documents in the form
of tags
A tag consists of text delimited by angle
brackets
The name of the tag identifies it and the
information which is conveyed by the tag
Markup
Markup
occur in pairs
A start tag
A matching end tag with a / before the tag name
The
XML
XML is one of in a long line of markup
languages
It is the eXtensible Markup Language
Unlike, other markup languages, you can
define your own tags
Any meaning associated with those tags is
imposed by your program
Uses of XML
SOAP
Simple
Configuration files
Web services
Security information
Electronic document exchange
Defining Documents
Type Definition
Schema
XML Structure
Attributes
size=large>Toronto</city>
11
<?xml
version=1.0
12
standalone
= no
In
address SYSTEM
address.dtd>
15
Elements
Smith</name>
16
Mixed Content
Smith</name>
are nested
<adverb>correctly</adverb></sentence>
17
Attributes
Attributes
<employee name=Jones>accountant<employee>
<employee name=Smith>sales<employee>
19
Comments
a comment -->
Comments can
Add explanations
Remove XML which is not needed for a while
20
Entities
<
&
The entity name
;
21
Entities
Entity
Symbol Description
<
<
Less than
>
>
Greater than
&
&
Ampersand
"
Double quote
'
apostrophe
22
CDATA
Sometimes using entities is not enough
since you have many special characters to
type
A CDATA section allows you to enter
anything without having special characters
interpreted
<![CDATA[
Person DTD
<!-- The DTD for person -->
<!DOCTYPE persontype [
<!ELEMENT person (first, last,
gender, employee-id) >
<!ELEMENT first (#PCDATA) >
<!ELEMENT last (#PCDATA) >
<!ELEMENT gender (#PCDATA) >
<!ELEMENT employee-id (#PCDATA) >
]>
25
first
last
gender
employee-id
26
XML Parsers
SAX
27
What is DOM?
28
Document
Root
Element
friend
handle
degree
whitespace
Text
Harold
close
Attribute
29
Nodes
All nodes in a DOM implement the Node
interface
All other interfaces in the tree extend the
Node interface
This means that every node can be
treated as a Node, and maybe more
30
XmlNode
Represents every node in the DOM
Properties
ParentNode
Name
FirstChild
NextSibling
PreviousSibling
Value
31
XmlNode
Methods
InsertBefore()
AppendChild()
RemoveChild()
Clone()
32
XmlDocument
DocumentElement
Methods
CreateElement()
CreateTextNode()
GetElementsByTagName()
Load()
Save()
33
XmlElement
Attributes
Methods
GetElementsByTagName()
SetAttribute(string
XmlAttribute
This is an attribute
Can have either Text nodes or
EntityReferences as children
Name property gets the name
Value gets the value
35
XmlText
This is the node representing text
The text has no markup
Even whitespace is represented as a text
node
36
CDATASection Interface
This is a CDATA section
It is similar to a text node but the content
undergoes no interpretation
37
These
38
DocumentFragment
Part
DOMImplementation
Prevides
39
DOMException
Something
NodeList
A list
went wrong
NamedNodeMap
A map
40
XmlDocument
XmlElement
XmlText
XmlAttribute
41
XmlNodeList
A list of nodes
Returned by GetElementsByTagName()
Properties
Count
Methods
Item(int
n)
-- retrieves a node
42
XmlNamedNodeMap
Methods
Item(int
n)
GetNamedItem(string name)
43
Examples
* see NodeLister
* see DocBuilder
44