Simple analysis of XML programming in Delphi

Source: Internet
Author: User
Tags character set

XML (extensible Markup Language Extensible Logo language) is the most eye-catching word in recent years in information magazines and websites. Large and small information products are scrambling to catch up with it, lest the fast train. Has a good reputation of the Blue (Borland) series development platform is no exception, since the 6.0 version of the integration of the XML component package, because of its use of Msxmldom parser, compared to the widely used Xmlparser parser, msxmldom More specification, Chinese compatibility better (element name , attribute names are supported in Chinese), are favored by developers. To help beginners quickly master the XML programming in Delphi, the author features this article for communication.

The author explains the steps of XML programming through an example of XML file, which can be easily understood by readers with the basic concepts of node, element and attribute. The XML file structure I want to read is shown below, named Input.xml.

<?xml version="1.0" encoding="GB2312"?>
<学生花名册>
<学生 性别 = "男">
<姓名>李华</姓名>
<年龄>14</年龄>
<电话>6287555</电话>
</学生>
<学生 性别 = "男">
<姓名>张三</姓名>
<年龄>16</年龄>
<电话>8273425</电话>
</学生>
</学生花名册>

The first line of the Input.xml file is the version description of the XML, the attribute encoding declares which character set is used, the default Unicode encoding (UTF-8 or UTF-16), and the Chinese GB2312 code here. The second line of "student roster" is the root element. The following defines two student elements, and the student has three child elements nested below, which is a further explanation for the student. Corresponding to this, we define the following student data structure in Delphi, "//" After the text is the description of the variable or statement, hereinafter.

TStudent = class {学生}
sex : string; //学生性别
name : string; //学生姓名
age : integer; //学生年龄
phone: string; //电话号码
end;

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.