Measure the test taker's knowledge about Dom4J parsing and Xpath writing.
Dom4J Quick Start
I. Using JAXP for SAX parsing (the logic is a little difficult)
1. SAX can only read documents
2,
<? Xml version = "1.0" encoding = "UTF-8" standalone = "no"?> // Start of the document
<Bookshelves> // start element // text
<Book Publishing House = "" No. = "A1"> // start with the element
<Title> Java employment training course </title>
<Author> Zhang Xiaoxiang </author>
<Price> 29 RMB </price>
<Wholesale price> 100 </wholesale price>
</Book>
<Book Publishing House = "Chuanzhi podcast" No. = "A2">
<Title> JavaScript web development </title>
<Author> Yu Yang </author>
<Price> 28.00 RMB </price>
</Book>
</Bookshelves> // element end
// End the document
Ii. JUnit unit test
3. Basic Dom4J exercises
4. Xpath: Find some/element or attribute
5. Use Dom4J to rewrite Small scores
6. Schema constraints (understand Schema, with emphasis on introducing Schema constraints in xml)
Namespace:
Html: table
Life: table
Com. itheima. a. A. class
Com. itheima. B. A. class
1. How to introduce schema constraints in xml
A. view the schema document and find the root element.
<? Xml version = "1.0" encoding = "UTF-8"?>
<Bookshelves>
</Bookshelves>
B. Which namespace does the bookshelf come from? View the schema document (because each schema document is bound to a namespace)
Introduce to our XML file
<? Xml version = "1.0" encoding = "UTF-8"?>
<Itheima: bookshelves xmlns: itheima = "http://www.itheima.com">
</Itheima: bookshelf>
C. Which xsd file does the namespace correspond? Specify the relationship between the two using schemaLocation
<? Xml version = "1.0" encoding = "UTF-8"?>
<Itheima: bookshelves xmlns: itheima = "http://www.itheima.com"
SchemaLocation = "http://www.itheima.com book. xsd">
</Itheima: bookshelf>
D. Which namespace does schemaLocation come from? From a standard namespace http://www.w3.org/2001/XMLSchema-instance
<? Xml version = "1.0" encoding = "UTF-8"?>
<Itheima: bookshelves xmlns: itheima = "http://www.itheima.com"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://www.itheima.com book. xsd">
</Itheima: bookshelf>