Java's first learning DOM creates XML file summary

zhaozj2021-02-16  101

Due to the project needs, I started learning Java and set up XML. It turned out that there were some other language-oriented foundations, but also aware of XML, so he first defeated himself. But there is still a bit of hard work in front of Java and Dom. After receiving countless information, there is a little eyebrow, brief self-contained, but also provide some clues to the old revolutions that face new issues.

This article is not a tutorial or technical article, just self-experience in personal learning. For the purpose of practical purposes, this article is mixed with the standard DOM model and JDOM (Javax.xml), and there is no clearness and temporarily ignoring many other excellent Parsers (such as apache). This article only involves the creation of XML and does not discuss reading.

Simple review of XML elements: pure text format, mark the data to be integrated, marked sensitive, each XML document can only have a root node, node (node) type: element (Element), comment (Comment), Processing Instruction, CDATA, Namespaces, Attribute. Show as follows:

View text editor (such as Notepad, UltraEdit) View:

John Smith

It can be seen that the text content does not change, only ensuring the semantics, and the format is determined by the browser. Finally, you need to explain that one point: Source is associated with the Document object once it is created. The Document tree changes Source automatically change, does not require our explicit action. That is to say, Source is not necessarily to be created before being transform (). Of course, it is impossible to expect Transformer to have this effect, because it's the goal is FileoutputStream, and it can only continue to append the disk.

转载请注明原文地址:https://www.9cbs.com/read-11394.html

New Post(0)