Home >Backend Development >XML/RSS Tutorial >A brief discussion on reading and editing XML documents

A brief discussion on reading and editing XML documents

黄舟
黄舟Original
2017-03-10 19:20:541778browse

This article mainly introduces the reading and editing of XML files. The most commonly used tools are of course the console and source code viewing in the browser. Friends in need can refer to

Reader
View the XML document using a simple text editor or any browser. Most major browsers support XML. XML files can be opened in the browser by double-clicking the XML document (if it is a local file) or entering the URL path in the address bar (if the file is located on the server). You can also open other files in the browser in the same way. XML files are saved with the ".xml" extension.

Let's explore the various ways in which you can view XML files. The following example (sample.xml) applies to all chapters in this chapter.


XML/HTML CodeCopy content to clipboard

  1. <?xml version="1.0"?>
    <contact-info>
        <name>Tanmay Patil</name>
        <company>TutorialsPoint</company>
        <phone>(011) 123-4567</phone>
    </contact-info>

Text Editor
Any simple text editor such as Notepad, Textpad or TextEdit can be used to create or view a XML document, as shown below:
A brief discussion on reading and editing XML documents

FireFox Browser
Double-click the file to open the above XML in FireFox, it will display the highlighted XML code, which makes the code more readable . It also displays a plus (+) and minus (-) sign to the left of the XML element. When we click on the minus sign (-) it hides the code and when we click on the plus sign (+) it expands the code. The output in FireFox will look like this:
A brief discussion on reading and editing XML documents

Chrome Browser
Open the above XML code in Chrome browser. The code is displayed as follows:
A brief discussion on reading and editing XML documents

Errors in the XML document
If some tags are missing in our XML code, the browser will display a information. We can try opening the following XML file in Chrome.


XML/HTML CodeCopy content to clipboard

  1. <?xml version="1.0"?>
    <contact-info>
        <name>Tanmay Patil</name>
        <company>TutorialsPoint</company>
        <phone>(011) 123-4567</phone>
    </ontact-info>

The opening and closing tags in the above code do not match (i.e. the _contactinfo tag), so the browser will display an error message as follows:
A brief discussion on reading and editing XML documents

We can also find professional online or downloadable XML editors, which have many powerful editing functions, such as:

Automatic closing tags.
Strict grammar checking.
XML syntax color highlighting facilitates readability.
can help us write effective XML code.
Provides the function of automatic verification of XML document DTD and schema.
Open source XML editor
The following provide some open source XML editors:

Xerlin: Xerlin is an open source editor based on the Apache license agreement under the Java 2 platform. It is a Java-based XML modeling application that can easily create and edit XML files.

CAM - Content Assembly Mechanism: CAM editor tool for XML+JSON+SQL Open+XDX sponsored by Oracle.


The above is the detailed content of A brief discussion on reading and editing XML documents. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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