XML Guide - XML ​​Code

xiaoxiao2021-03-05  26

XML documents can include foreign characters such as Norwegian or French (Chinese Of course! This part can still be translated by the original text, some of the following content is written by I.)

In order to make your parser understand these characters, you must unify the character coding standard in the XML document.

Windows 95/98 Notepad

Windows 95/98 Notepad cannot be saved in Unicode's encoded format.

You can use the notepad to edit and save an XML document containing foreign characters (such as Norwegian or French or Chinese)

小 奀

Xiaolin

Go to the hot pot together

But if you open this XML document edited by the browser, an error will appear Open IT WITH IE 5.0.

Using the code in Windows 95/98 Notepad

Windows 95/98 Notepad Editing an XML file must be encoded attribute settings.

To avoid errors, you can add an encoding property in the XML document declaration, indicating the encoding type of this XML document, but do not use Unicode encoding.

The following encoding type does not cause errors, and the Chinese characters are displayed normal:

The following encoding type does not cause errors, and the Chinese characters are displayed normal:

The following encoding type does not cause errors, and the Chinese characters are not normal (garbled):

The following encoding type does not cause errors, and the Chinese characters are not normal (garbled):

The following encoding type does not cause errors, and the Chinese characters are displayed normal:

The following encoding type will result in an error:

Use Windows 2000 Notes

Windows 2000 Notepads can save files in a Unicode encoding format.

WINDOWS 2000 Notepad supports the Unicode character set. If you use Win2000's Notepad Save an XML document in Unicode's encoded format (note that there is no encoded information in the XML declaration):

小 奀 Xiaolin Going to hot pot together

Below this file; Note_Encode_none_u.xml, there will be no errors in IE5.0 , but if you use Netscape 6.2, it may be wrong. The reader compares the two files of Note_Encode_none.xml and Note_Encode_none_u.xml, if they look at their respective source files, but why can I display, one can't display? The answer is the Unicode character set.

Windows 2000 Notepad Code

Windows 2000 Notepads can also save files in "UTF-16" encoding format.

If you declare encoding properties in an XML document, save files in a Unicode encoding format, and errors may occur.

The following code will result in an error:

The following code will result in an error:

The following code will result in an error:

Below this file; Note_Encode_utf16_u.xml will be displayed in IE5.0 , and an error will occur in Netscape 6.2 browser.

Error message

When you browse the XML document with IE5.0 or later, you may encounter different coding errors in two.

An illegal character is found in the text content (An Invalid Character Was Found In Text Content).

If your XML document is not matched with your XML document, it may cause an error to occur. Normally, the XML document contains some "non-English" characters and uses a single-byte encoded editor, and does not set the encoding format of the XML document in the declaration of the XML document. No support from the current encoding format into another coding format (Switch From Current Encoding to Specified Encoding Not Supported).

If the XML document is saved in Unicode / UTF-16 encoding format, but the encoded format is set in the declaration of the XML document (such as Windows-1252, ISO-8859-1 or UTF-8); or XML The document is saved in single-byte coding format, but the declaration of the XML document is set in the encoding format of some Unicode / UTF-16, which will cause errors.

in conclusion

Conclusion: Set the encoding format of the document in the declaration of the XML document before saving the XML document, some of my recommendations for avoiding errors:

Use a editor that supports Unicode encoding format. Confident, you know that you are using that coding format. Use the properties declaration to set the encoding format in the XML document.

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

New Post(0)