XML Classic FAQ _xml Basics

Source: Internet
Author: User
Tags trim xml parser xsl
Why do you want to develop XML when HTML has become so popular?

Simply put, HTML can't be done, we want the XML to do the task. The reason is simple, the task that the XML is to complete must be done by the Meta Markup Language, and HTML is just an instance of the banner statement. Prior to the release of XML, the development of the Internet was constrained by several issues of HTML:
1 HTML can not describe the content of the data, which is precisely the data retrieval, E-commerce is necessary.
2 HTML description of the data performance is not enough, such as HTML can not describe vector graphics, scientific symbols and other objects, at present only through the image to represent these objects.
3 The position of HTML instance Markup language is completely unable to meet the needs of the development of new labeling requirements.
The emergence of XML, so that the above problems are well resolved.
Imagine that in the Internet world, if we all speak dialects and exchange information with each other to translate, it will be a very difficult to communicate and communicate in the world. In the Internet world, XML is important, precisely because it plays the role of "international language". In addition, XML provides a tool for defining "jargon" in all walks of life in a more internet world.

two. How do I read XML in a browser?

The tools for reading XML documents are commonly referred to as XML parsers, also known as XML processors. The XML processor transmits data to the application software for processing, publishing, querying, or displaying. XML does not provide application interfaces (APIs) to applications, it simply passes data to the application software. XML processors do not parse data that is not well constructed. Both Netscape and Microsoft have included XML parsers in their browsers. The XML Developer community provides free XML readers and parsers to be used in application software or XML production software.

three. Why use XML instead of HTML?

The more important reasons are the following six:
1 authors and vendors can use XML to design their own document types without being constrained by HTML.
2 because XML has a much greater ability to hypertext link than HTML, XML provides richer information content than HTML and is easier to use.
3 XML provides more and better mechanisms to facilitate browser information performance and optimize performance.
4 XML discards the complexity of SGML, so it's easy to write an application that processes XML.
5 information is easy to store and can be reused.
6 XML files are also available in SGML environments and are not necessarily limited to use in the Web.

Four. Can I create and manage XML files in Java?

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

Five. Why is the analysis result of XML file garbled?

This is caused by a coding problem. The XML standard stipulates that the XML parser must support "UTF-8" and "UTF-16" encodings, and must be able to distinguish between the two encoded files automatically, and does not require support for other encodings (including the commonly used Chinese encoding "GB2312" or "BIG5"). If an XML file contains an encoding declaration, the parser processes it according to the declared encoding, otherwise it is processed according to the recognition result (the result is always one of "UTF-8" and "UTF-16"). Therefore, if the XML file is encoded in both of these, you must precede the XML file with the encoding declaration, such as: <?xml version= "1.0" encoding= "gb2312"?> to indicate that the encoding of the XML file is "gb2312".

Most of the existing XML parsers do not support Chinese-encoded "GB2312" or "BIG5", so XML files containing Chinese cannot be read. You can use a parser that supports Chinese encoding, such as MSXML,IBMJAVA4C,IBMJAVA4J, for XML analysis. You can also use the Internal Code conversion tool, convert the encoding to "UTF-8" or "UTF-16" to parse, and then convert the parse result back to the original encoding. The Ccnv (Code Converter) in the software garden of this site is such a tool. Of course, you can also write an internal code conversion program.

For more information on "UTF-8" and "UTF-16" encodings, see the UTF-16 and UTF-8 standards in the standard highlights of this site.

Six. How does XML connect to the database?


XML is a file format, it does not specify the way to connect with the database, you need to use the traditional method to connect the database, database query, and then the query results into XML format. There are a number of tools that are now available to connect XML to the database, and most follow this step. The following is an example of using ASP to generate XML files directly, and you can access http://www.xml.net.cn/Asps/test/roster1.asp to view the execution effect.
Copy Code code as follows:
<%@ language= "VBScript"%>
<?xml version= "1.0" encoding= "gb2312"?>
<?xml:stylesheet type= "text/xsl" href= ". Image Oster.xsl "?>
<roster>
<%
Set cconn = Server.CreateObject ("ADODB. Connection ")
Call Cconn.open ("DSN", "USER", "PWD")
Set rs = Cconn.execute ("Select DISTINCT * from Roster")
Do but not Rs. EOF%>
<Record>
<name><%=trim (RS ("Name"))%></name>
<nativeplace><%=trim (RS ("Nativeplace"))%></nativeplace>
<age><%=trim (RS ("age"))%></age>
<telephone><%=trim (RS ("telephone"))%></telephone>
</Record>
<% Rs. MoveNext
Loop
Rs. Close
Set rs=nothing
Set cconn=nothing
%>
</roster>

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.