Java Beginners use Dom to create XML file Summary

Source: Internet
Author: User

Due to project needs, I started to learn Java and play with XML. I used to have some object-oriented basics in other languages and have some knowledge about XML. Therefore, I beat myself in the first place. But the two new things of Java and Dom are still a little difficult. Having read numerous materials, I have a little bit of eye-catching. I will briefly summarize myself and provide some clues to the old revolutionaries who are also facing new problems.

This article is not a tutorial or technical Article, but a personal experience in learning. For practical purpose, this article describes the standard DOM model and JDOM (javax. XML) mixed, not clearly identified, and temporarily ignored many other excellent parsers (such as APACHE ). This article only involves the creation of XML and does not discuss reading.

A brief review of XML elements: in plain text format, tags enclose data in an ideographic manner and indicate case sensitivity. Each XML document can have only one root node, node type: element, comment, processing instruction, CDATA, namespaces, and attribute ). As shown below:




View in a text editor (such as Notepad and ultraedit:

John Smith
It can be seen that the text content does not wrap, and only the semantics is correct. The format is determined by the browser.

Note: Once a source is created, it is associated with the document object. The document tree automatically changes the source without explicit action. That is to say, the source does not have to be created before being transform. Of course, transformer cannot be expected to have this effect, because its target is fileoutputstream, and the disk can only be appended if it is written.

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.