1. Basic Knowledge (Extensible Markup Language)
<? XML version = "1.0"?> <Note> <to> Tove </to> <from> Jani </from>
- Good format (guaranteed by its own syntax)
- Validity (guaranteed by DTD or schema)
2. DTD (document type definition)
1) Internal DTD
<? XML version = "1.0" ?>
<! Doctype note [
<! Element note (to, from, heading, body) >
<! Element to (# pcdata) >
<! Element from (# pcdata) >
<! Element heading (# pcdata) >
<! Element body (# pcdata) >
]>
< Note >
< To > Tove </ To >
< From > Jani </ From >
< Heading > Reminder </ Heading >
< Body > Don't forget me this weekend </ Body >
</ Note >
2) External DTD
Note. xml
<? XML version = "1.0" ?>
<! Doctype note system "note. DTD" >
< Note >
< To > Tove </ To >
< From > Jani </ From >
< Heading > Reminder </ Heading >
< Body > Don't forget me this weekend! </ Body >
</ Note >
Note. DTD
<!Element note (to, from, heading, body)>
<!Element to (# pcdata)>
<!Element from (# pcdata)>
<!Element heading (# pcdata)>
<!Element body (# pcdata)>
Why use DTD?
- Self-description
- It can be used for information exchange.
3) XML Schema
Note. xml
<? XML version = "1.0" ?>
< Note
Xmlns = "Http://www.w3schools.com"
Xmlns: xsi = "Http://www.w3.org/2001/XMLSchema-instance"
Xsi: nonamespaceschemalocation = "Note. XSD" >
< -- Xsi: schemalocation = "Http://www.w3schools.com note. XSD" -- >
< To > Tove </ To >
< From > Jani </ From >
< Heading > Reminder </ Heading >
< Body > Don't forget me this weekend! </ Body >
</ Note >
Note. XSD
<? XML version = "1.0" ?>
< Xs: Schema Xmlns: XS = "Http://www.w3.org/2001/XMLSchema"
Targetnamespace = "Http://www.w3schools.com"
Xmlns = "Http://www.w3schools.com"
Elementformdefault = "Qualified" >
< Xs: Element Name = "NOTE" >
< Xs: complextype >
< Xs: Sequence >
< Xs: Element Name = "" Type = "XS: string" />
< Xs: Element Name = "From" Type = "XS: string" />
< Xs: Element Name = "Heading" Type = "XS: string" />
< Xs: Element Name = "Body" Type = "XS: string" />
</ Xs: Sequence >
</ Xs: complextype >
</ Xs: Element >
</ Xs: Schema >
Why use schema?
- Supports more Data Type Definitions
- You can use XML syntax
- Ensure correct data exchange
- Scalable
- Good form does not meet requirements
The above is the overall content of http://www.w3schools.com.
4) document addressing language xpath
Document addressing language XPath is a member of the XSL (Extensible Stylesheet Language) family. It is also the common basis for XML-related technologies such as XSLT, xpointer, and XQuery.
From the perspective of XPath, the entire XML document tree consists of a series of nodes.
5) XML Parsing Method
- SAX (Event-based parsing method, partial loading)
- dom (loading all, too much memory consumption, improvement method: loading subtree, delayed reading)
- XML beans architecture (using XML schema to generate helper classes)
- the Java architecture for Java binding (jaxb)