Day05-xml restriction and analysis of the Java EE Employment class in the 168 phase of Chuan Zhi

Source: Internet
Author: User
Tags cdata tag name

* Curriculum Review:
* Introduction to DOM parsing HTML
* DOM Document Object model
* Parser

* Document Object
* getElementById ("value of id"); Returns an element (label) object
* Getelementsbyname ("name"); return array
* getElementsByTagName ("tag name"); return array

* Create an Element object
Document.createelement ("element name");
document.createTextNode ("text content");
AppendChild (node); The parent node calls the method
InsertBefore (new,old) to add a child node before the specified node

* Element Object
* Operation Properties SetAttribute ("", "") set or modify properties
GetAttribute ("attribute name");
RemoveAttribute ("attribute name");

* Get child nodes
getElementsByTagName ("element name of the child node");

* Node Nodes Object
* Nodenamenodetype NodeValue
* ParentNode Parent Node (* * * * *)

* AppendChild (node); The parent node calls the method
* InsertBefore (new,old) adds a child node before the specified node
* ReplaceChild (new,old) Replacement node
* RemoveChild (node) Delete node
* CloneNode (true or False) copy node

* innerHTML get and set text content
<span></span>

* Event
* OnClick Click event
* OnDblClick Double-click Event
* OnLoad Load Event
* Onfoucs Get focus
* Onblur loses focus
* OnChange Change Event


* OnSubmit Control form submission

=============================================================================================================
* OnSubmit Event
* Control Form Submission. Need to put onsubmit action on the form <form onsubmit= "" >
* The notation of the value: onsubmit= "return run ()"
* Run () must have a return value and must return TRUE or False.
* If the return is true, the form can be submitted, and if it returns false, the form cannot be submitted. If there is no return value, the default is form Submission.
* What does the logic of run () write?
* Check the Form.

* Form can be submitted via Js.
Get form by ID
var form = document.getElementById ("formId");
Get a form through the properties of the Form's name
var form = document.form1;
var name = document.form1.username.value;
Alert (name);

Set the path of the submission
Form.action = "success.html";
Form.method = "get";
Submit Form
Form.submit ();


* XML (* * * *)

* Introduction to XML
* XML Extensible Markup Language. (very similar to HTML)
* Extensible.
* Customize the Label.

* XML transmits data, HTML is display Data.

* Version of Xml: XML1.0 (using this version) XML1.1 (not backwards Compatible)
* What do you do with it?
* Describe the data that is related

* Application
* As a configuration File.

* Data transfer between the system and the system is Possible.
* Webserivicesoapxml Package data
* JSON and XML concepts

* Syntax FOR XML
* Document Declaration (* * * * *)
* Notation: <?xml version= "1.0"?>
* The document declaration must appear in the first and first column locations of the XML file.

Properties
* version= version of "1.0" XML (must be written)
* encoding= "UTF-8" encoding set (optional)
* standalone= "yes or no" indicates whether the XML file is Independent. (if no, not independent, can introduce external files) (optional)
* Because this property is not written, external files can be Introduced.

* Garbled will accompany your life?
* Cause: the encoding used when saving the file and opening the file is Inconsistent.
* Workaround: Save the file to open the file using the same encoding as Ok. (myeclipse does not cause garbled Problems)


* Element (* * *)
* Start tag and end Tag.
* contains tag body:<abc> text </abc>
* Does not include the label body:<abc/>

* Cannot cross-nest
* Only one root element (must have, and only one)

* Naming specification:
* Case-sensitive:<a></a> represent two tags
* Cannot start wrong:<1a><-a> with numbers and-dashes
* Cannot start with an XML (xmlxml XML) error:<xmlaa>
* cannot contain spaces and colons.

* Attributes (* * *)
* custom: naming specification Ibid.
* cannot have the same attribute on the same element. (*****)
* double quotes or single quotes can be Used.


* Note (*)
* Same as HTML comments
<!--xml comments--

* Comments cannot be nested.

* Special Characters
* <&lt;
* >&gt;
* &&amp;
* "&quot;
* ' &apos;

* CDATA Zone
* Use the contents of the tag as a string.
Syntax
<! [cdata[
Content: as a string
]]>

* PI (processing Instructions) (forgot)
* Replace HTML


* Constraints of XML
* DTD
* Schema

<myspring>
<bean>hello.java</bean>
< cat/>
</myspring>

* Well-Formed Xml: follows the syntax Specification.
* Valid Xml: Constrained.


* DTD constraints
* Quick Start
* Quick Start Steps:
* What labels do I need to appear?
* Writing elements in a DTD file
<! element element name elements type >
* Determine if the element is complex or simple?
* If it is a simple element: (#PCDATA) represents a string
* If it is a complex element: (child Node)

* files that need to be introduced in Book.xml DTD
* <! DOCTYPE root node SYSTEM "dtd file address" >

* How DTDs are associated with XML documents
* The DTD code can be written directly in the XML file. (often Used)
<! DOCTYPE root Node [
The code for the DTD
]>

* Introduction of local DTD files (frequently used)
<! DOCTYPE root node SYSTEM "dtd file address" >

* Introduction of DTD files on the network
<! DOCTYPE root node public "dtd file name" "dtd file address" >


* Element definition
* Syntax: <! element element name elements type >

* (#PCDATA) String
* Empty space
* Any arbitrary
* (child Element)

* Child Elements:
* The relationship between child elements
*, child elements appear in order
* | Child elements can only appear with one

* Number of occurrences of child elements
* + child element appears 1 or more times
* * child element appears 0 or more times
* child element appears 0 or 1 times

<! ELEMENT MYFILE (title*, AUTHOR?, EMAIL) * | COMMENT) >

<MYFILE>
<TITLE></TITLE>
<AUTHOR></AUTHOR>
<EMAIL></EMAIL>
<TITLE></TITLE>
<AUTHOR></AUTHOR>
<EMAIL></EMAIL>
<TITLE></TITLE>
<AUTHOR></AUTHOR>
<EMAIL></EMAIL>
</MYFILE>



* Attribute Definition (attributelist)
* Wording: <! attlist element name
Property Name Property Type property constraint
Property Name Property Type property constraint
>
* Attribute Type
* CDATA String
* Enumeration (no keywords Provided) (men | women)
* ID represents a unique value and cannot be written in numbers only

* Attributes are constrained
* #REQUIRED必须出现的
* #IMPLIED可选的
* #FIXED固定值 #fixed "value"
* Default Value (not used)

* Entity definition (not much used)
* <! ENTITY alias "value" >
* You need to introduce aliases in the xml, and when the browser opens the file, it displays the value in the introduced Location.



* Parsing xml
* What are the ways to parse xml?
* There are two kinds of commonly used? Dom and sax
Difference
DOM Parsing xml
* Form a tree structure in memory
* Cons: If the document is too large, it is prone to memory overflow problems.
* Advantages: easy to do and delete and change the operation

Sax parsing
* event-driven, Edge-read Edge Parsing
* Advantage: no memory overflow Issue.
* Disadvantages: can not do additions and deletions to change Operation. (dom4j in memory spanning tree Structure)

*, only use Dom mode, if sax, can only do query.
* DOM4J (* * * * *) provided by Jaxpsun
* Want to do additions and deletions to enterprises are in Use. Provided by dom4j
* All can be done.
* JDOM (not Spoken)


* Parsing HTML for JAXP
* DOM
* Documentbuilderfactory: Parser Factory class
* Documentbuilder Get Parser Object
* Parse XML (Document parse (String URI))
Get Parser Factory class
Documentbuilderfactory factory = Documentbuilderfactory.newinstance ();
Get Parser Object
Documentbuilder builder = Factory.newdocumentbuilder ();
Parses the XML document and returns the file object
Document document = Builder.parse ("src/book2.xml");


* Write back
* Get back to write factory class
* Get Write-back Object
* Callback method is called to write Back.
Create a factory that writes back classes
Transformerfactory transformerfactory = transformerfactory.newinstance ();
Get Write-back Class
Transformer Transformer = Transformerfactory.newtransformer ();
Method of calling write back
Transformer.transform (new domsource (document), new Streamresult ("src/book2.xml"));



* job: node InsertBefore (node newChild, node Refchild)
To add a child node before the specified node


* Update the contents of the node


* Gets the property value of the tag

Day05-xml restriction and analysis of the Java EE Employment class in the 168 phase of Chuan Zhi

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.