Java basics-six typical questions and answers about XML

Source: Internet
Author: User
Tags xml parser xml reader
Java basics-six typical xml q & A-general Linux technology-Linux programming and kernel information. For details, refer to the following section. I. HTML is so popular. Why should we develop XML?

Simply put, HTML cannot be completed, and we want the task to be completed in XML. The reason is very simple. The task to be completed in XML must be completed by the meta-tagline, while HTML is just an example of the tagline. Before the XML Release, the development of the international Internet was constrained by the following HTML issues:

1) HTML cannot describe data content, which is exactly what is necessary for data retrieval and e-commerce.
2) HTML cannot describe the data performance. For example, HTML cannot describe vector graphics, scientific symbols, and other objects. Currently, it can only express these objects through images.
3) HTML instances set up the status of slogans, which cannot meet the development needs of new markup.

The emergence of XML makes the above problems well solved.

Imagine how hard it would be to communicate and communicate in the Internet world if everyone speaks dialects and exchanges information with each other. In the Internet world, XML is important because it plays the role of "international language. In addition, XML provides the Internet world with tools to define "terminologies" in various industries.

2. How to read XML in a browser?

A tool for reading XML documents is generally called an XML Parser or an XML processor. The XML processor transfers data to application software for processing, publishing, querying, or displaying. XML does not provide application interfaces (APIS) to application software. It only transmits data to the application software. XML processor and does not parse unstructured data. Both Netscape and Microsoft have included the XML parser in their browsers. The XML developer Group provides a free XML reader and parser for applications in application software or XML production software.

3. Why should we use XML instead of HTML?

There are six important reasons:
1) Authors and suppliers can use XML to design their own document types without being constrained by HTML.
2) XML provides more information and easier to use than HTML because of its better hypertext link capabilities.
3) XML provides more and better mechanisms to facilitate browser information performance and optimize performance.
4) XML removes the complexity of SGML, so it is easy to write an application that processes XML.
5) information is easy to store and can be reused.
6) XML files can also be used in the SGML environment. They are not necessarily limited to WEB applications.

4. Can I use Java to create and manage XML files?

Yes, any programming language can be used to output data from source documents in XML form. Many front-end and back-end tools have emerged to make program design and data management more convenient. The following two URLs have a more detailed description: http://www.markwatson.com/XMLdb_0_1.htm http://developerlife.com

5. Why are the analysis results of XML files garbled?

This is caused by encoding problems. The XML standard requires that the XML analyzer must support both UTF-8 and UTF-16 encoding, and must be able to automatically distinguish between the two encoding files, other codes (including commonly used Chinese codes "GB2312" or "BIG5") are not required. If the XML file contains an encoding statement, the analyzer processes the statement according to the declared encoding, otherwise it is processed according to the recognition results (the recognition results are always one of the "UTF-8" and "UTF-16 ). Therefore, if the encoding of an XML file is beyond these two types, you must add the encoding declaration before the XML file. For example, the encoding of the XML file is "gb2312 ".

Most existing XML analyzer does not support Chinese encoding "GB2312" or "BIG5", so it cannot read XML files containing Chinese characters. You can use analyzer that supports Chinese encoding, such as MSXML, IBMJAVA4C, and IBMJAVA4J for XML analysis. You can also use an internal code conversion tool to convert the code to "UTF-8" or "UTF-16" for parsing, and then convert the parsing result back to the original encoding. Code Converter in the software park on this site is such a tool. Of course, you can also write an internal code conversion program by yourself.

For more information about "UTF-8" and "UTF-16" encoding, see the UTF-16 and UTF-8 standards in this site's standard collection.

6. How does XML connect to the database?


XML is a file format. It does not specify the connection method to the database. You need to connect to the database using the traditional method for database query, and then convert the query result to XML format. Currently, some tools provide the following steps for connecting XML to databases. The following is an example of using ASP to directly generate an XML file. You can access http://www.xml.net.cn/asps/test/roster1.asp?execution result.
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.