Home Backend Development XML/RSS Tutorial Detailed introduction on how to edit xml files

Detailed introduction on how to edit xml files

Mar 29, 2017 pm 03:48 PM

XMLThe document can contain foreign characters such as Norwegian or French (Chinese is also acceptable! This part still cannot be translated according to the original text, some of the following content is written by myself)

For For your parser to understand these characters, you must adopt a consistent character encoding standard in the XML document.

-------------------------------------------------- ------------------------------------

Windows 95/98 Notepad
Windows 95/98 Notepad cannot save files in Unicode encoding format.

You can use Notepad to edit and save XML documents containing foreign characters (for example: Norwegian or French or Chinese)

<?xml version="1.0"?>
<note>
<from>小奀</from>
<to>小林</to>
<message>晚上一起去火锅呀</message>
</note>
Copy after login

But if you open this with a browser and edited it with Notepad XML document, an error will occur.

-------------------------------------------------- ------------------------------------

in Windows 95/98 Notepad Using encoding
Windows 95/98 Notepad to edit XML files must set the encodingattribute.

In order to avoid errors, you can add an encoding attribute to the XML document declaration to indicate the encoding type of this XML document, but do not use Unicode encoding.

The following encoding type will not cause errors, and Chinese characters will be displayed normally:

<?xml version="1.0" encoding="gb2312"?>
Copy after login

The following encoding types will not cause errors, and Chinese characters will be displayed normally:

<?xml version="1.0" encoding="gbk"?>
Copy after login

The following encoding type will not cause errors, and Chinese characters will not be displayed normally (garbled characters):

<?xml version="1.0" encoding="windows-1252"?>
Copy after login
Copy after login

The following encoding types will not cause errors, and Chinese characters will be displayed abnormally (garbled characters) :

<?xml version="1.0" encoding="ISO-8859-1"?>
Copy after login
Copy after login

The following encoding types will not cause errors, and Chinese characters are displayed normally:

<?xml version="1.0" encoding="UTF-8"?>
Copy after login
Copy after login

The following encoding types will cause errors:

<?xml version="1.0" encoding="UTF-16"?>
Copy after login
Copy after login

--------------------------------------------- ----------------------------------

Using Windows 2000 Notepad
Windows 2000 Notepad can save files in Unicode encoding format.

Notepad for Windows 2000 supports Unicodecharacter set. If you use Win2000 Notepad to save the XML document in Unicode encoding format (please note that there is no encoding information in the XML declaration):

<?xml version="1.0"?>
<note><from>小奀</from><to>小林</to><message>晚上一起去火锅呀</message></note>
Copy after login

---------------- -------------------------------------------------- --------------

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

If you declare the encoding attribute in the XML document and save the file in Unicode encoding format, an error may occur.

The following code will cause an error:

<?xml version="1.0" encoding="windows-1252"?>
Copy after login
Copy after login

The following code will cause an error:

<?xml version="1.0" encoding="ISO-8859-1"?>
Copy after login
Copy after login

The following code will cause an error:

<?xml version="1.0" encoding="UTF-8"?>
Copy after login
Copy after login

The following file; note_encode_utf16_u.xml, will display normally in IE5.0+, but will cause an error in Netscape 6.2 browser.

<?xml version="1.0" encoding="UTF-16"?>
Copy after login
Copy after login

---------------------------------------- -------------------------------------

Error message
When using IE5.0 or higher to browse XML documents, you may encounter two different encoding errors:

An invalid character was found in the text content (An invalid character was found in text content).

If your XML document does not match the encoding format of your XML document, an error may occur. Usually, the XML document contains some "non-English" characters and uses single-byte encoding Editor, and the encoding format of the XML document is not set in the declaration of the XML document.

Conversion from the current encoding format to another encoding format is not supported (Switch from current encoding to specified encoding not supported ).

If the XML document is saved in Unicode/UTF-16 encoding format, but the declaration of the XML document sets the encoding format to be some single-byte encoding (such as Windows-1252, ISO-8859-1 or UTF -8); or the XML document is saved in a single-byte encoding format, but the declaration of the XML document sets the encoding format to be some Unicode/UTF-16 encoding form. Both situations will cause errors.

-------------------------------------------------- ------------------------------------

Conclusion
Conclusion: After saving Before setting the encoding format of the document in the declaration of the XML document, some of my suggestions to avoid errors:

Use an editor that supports Unicode encoding format.
Make sure you know which encoding format you are using.
Use attribute declarations to set the encoding format in XML documents.

The above is the detailed content of Detailed introduction on how to edit xml files. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Can I open an XML file using PowerPoint? Can I open an XML file using PowerPoint? Feb 19, 2024 pm 09:06 PM

Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

Convert XML data to CSV format in Python Convert XML data to CSV format in Python Aug 11, 2023 pm 07:41 PM

Convert XML data in Python to CSV format XML (ExtensibleMarkupLanguage) is an extensible markup language commonly used for data storage and transmission. CSV (CommaSeparatedValues) is a comma-delimited text file format commonly used for data import and export. When processing data, sometimes it is necessary to convert XML data to CSV format for easy analysis and processing. Python is a powerful

Handling errors and exceptions in XML using Python Handling errors and exceptions in XML using Python Aug 08, 2023 pm 12:25 PM

Handling Errors and Exceptions in XML Using Python XML is a commonly used data format used to store and represent structured data. When we use Python to process XML, sometimes we may encounter some errors and exceptions. In this article, I will introduce how to use Python to handle errors and exceptions in XML, and provide some sample code for reference. Use try-except statement to catch XML parsing errors When we use Python to parse XML, sometimes we may encounter some

How to restore the deleted hosts file How to restore the deleted hosts file Feb 22, 2024 pm 10:48 PM

Title: How to restore the hosts file after deletion Summary: The hosts file is a very important file in the operating system and is used to map domain names to IP addresses. If you accidentally delete the hosts file, you may be unable to access certain websites or have other network problems. This article will introduce how to recover accidentally deleted hosts file in Windows and Mac operating systems. Text: 1. Restore hosts file in Windows operating system. Hosts file in Windows operating system

How to edit documents in Tencent Docs? -Tencent Document Editing Document Tutorial Guide How to edit documents in Tencent Docs? -Tencent Document Editing Document Tutorial Guide Mar 19, 2024 am 08:19 AM

Does anyone know how to edit documents in Tencent Docs? It doesn't matter if you don't know. Today, the editor will introduce detailed graphic explanations on how to edit documents in Tencent Docs. I hope it can help you. Detailed graphic explanation of editing documents in Tencent Documents 1. First, enter Tencent Documents directly (if you don’t have it, download it now!) and log in directly (QQ and TIM two login methods are supported) 2. After logging in, click Add in the upper right corner No., directly create online documents, online forms, new folders, etc.! 3. Then enter the information according to your needs!

Python parsing special characters and escape sequences in XML Python parsing special characters and escape sequences in XML Aug 08, 2023 pm 12:46 PM

Python parses special characters and escape sequences in XML XML (eXtensibleMarkupLanguage) is a commonly used data exchange format used to transfer and store data between different systems. When processing XML files, you often encounter situations that contain special characters and escape sequences, which may cause parsing errors or misinterpretation of the data. Therefore, when parsing XML files using Python, we need to understand how to handle these special characters and escape sequences. 1. Special characters and

What to do if word document cannot be edited What to do if word document cannot be edited Mar 19, 2024 pm 09:37 PM

After editing the document, we will save the document to provide convenience for editing and modifying the document next time. Sometimes we can modify it directly after clicking on the edited document, but sometimes for some unknown reason, there is no response no matter how we click on the word document, and the command will not be executed. , what should I do if the word document cannot be edited? Don’t worry, the editor will help you solve this problem. Let’s take a look at the operation process. After opening a Word document, when editing text, you will see a &quot;Restrict Editing&quot; prompt displayed on the right side of the page, as shown in the figure below. 2. You need to cancel editing and you need to know the set password. Click &quot;Stop Protection&quot; below the pop-up prompt, as shown in the figure below. 3. Then enter the password in the &quot;Unprotect Document&quot; dialog box and click OK, as shown in the figure below.

How to handle XML and JSON data formats in C# development How to handle XML and JSON data formats in C# development Oct 09, 2023 pm 06:15 PM

How to handle XML and JSON data formats in C# development requires specific code examples. In modern software development, XML and JSON are two widely used data formats. XML (Extensible Markup Language) is a markup language used to store and transmit data, while JSON (JavaScript Object Notation) is a lightweight data exchange format. In C# development, we often need to process and operate XML and JSON data. This article will focus on how to use C# to process these two data formats, and attach

See all articles