当前位置:网站首页>XML Configuration File

XML Configuration File

2022-07-06 00:21:00 16000 mu of roses that turn the world upside down

Preface :(*゚ヮ゚)* I wrote this article with XML Relevant basic knowledge ,  Next, I will write a few more articles about XML The article , Interested families can have a look ヾ(•ω•`)o

Catalog

 XML Format

What is? XML?

XML The role of

1. Data exchange

2.Web service

3. Content management

4.Web Integrate

5. Preparation

The standard XML Format  

Element definition

  Case study

Attribute definitions

  Case study


XML Format

What is? XML?

eXtensible Markup Language (XML) Extensible markup language ( A subset of Standard General Markup Languages ) It is a simple data storage language .

Use a series of simple tags to describe the data , And these tags can be created in a convenient way , Although extensible markup language takes up more space than binary data , But extensible markup language is extremely simple and easy to master and use .

Extensible markup language ( A subset of Standard General Markup Languages )

                                                                                                        ———— Baidu Encyclopedia

XML The role of

(XML The source of the original text is Baidu Library https://wenku.baidu.com/view/47802df483eb6294dd88d0d233d4b14e85243ee8.html

1. Data exchange

⽤XML In response to ⽤ It's no secret that programs exchange data with companies , Milli ⽆ Questions should be listed as ⼀ position .
So why XML In this field ⾥ Your position is so important ? The reason is that XML send ⽤ Elements and attributes to describe numbers
According to the . In the process of data transmission ,XML Always keep things like ⽗/⼦ Data structures like relationships .⼏ One should ⽤ Program
You can share and resolve the same ⼀ individual XML⽂ Pieces of , There is no need to make ⽤ Traditional string parsing or disassembly process .
contrary , Ordinary ⽂ Pieces do not describe each data segment ( Except in the head ⽂ In the piece ), Nor does it preserve the data relational structure . send
⽤XML Doing data exchange can make ⽤ The program is more flexible , Because it can ⽤ Location ( And ordinary ⽂ Pieces of ⼀ sample ) or ⽤ element
Prime name ( From database ) To access XML data .

2.Web service

Web Service is the most important ⼈ Excited ⾰ Life is ⼀, It makes ⽤ Different systems and different programming languages ⾔ Of ⼈ We can communicate with each other
Stream and share data . It is based on Web The server ⽤XML Exchange data between systems . Exchanging data usually ⽤XML mark
remember , It can standardize the agreement ⼀ Cause ,⽐ For example, in the simple object processing protocol (Simple Object Access Protoc 
ol, SOAP) On the platform .
SOAP Can be in ⽤ Different programming languages ⾔ Passing messages between constructed objects . It means ⼀ individual C# Objects can be associated with ⼀ individual
Java Object into ⾏ Communications . This kind of communication is very ⾄ Can send ⽣ In transit ⾏ Between objects on different operating systems .DCOM 
, CORBA or Java RMI Messages can only be passed between tightly coupled objects ,SOAP Can be passed between loosely coupled objects
Deliver a message .

3. Content management

XML only ⽤ Elements and attributes to describe data ,⽽ Do not provide data display ⽰⽅ Law . such ,XML Provided. ⼀ The best
Elegant ⽅ FA Lai marks Du ⽴ In platform and language ⾔ The content of .
send ⽤ like XSLT Such words ⾔ Can easily XML⽂ Pieces are converted into various formats ⽂ Pieces of ,⽐ Such as HTML, WML, PD 
F, flat file, EDI, wait .XML Have the ability to transport ⾏ Between different system platforms and into different formats
⽬ mark ⽂ This piece can ⼒ Make it content management should ⽤ Excellent choice in the system .

4.Web Integrate

Now there are more and more devices ⽀ a XML 了 . bring Web Developers can be in ⼈ electric ⼦ Between assistants and browsers
⽤XML To transfer data .
Why will XML⽂ Ben sent it directly to such a device ? In this way ⽬ What's important is to let ⽤ More households ⾃⼰ Master the data
display ⽰⽅ type , Can experience the happiness of practice more . Regular customers / service (C/S)⽅ Formula in order to get data sorting or more
Fade ⽰ Format , You must send an application to the server ;⽽XML Data can be processed directly , There is no need to apply to the server
Please check - Return the result in such a two-way “ Journey ”, At the same time, the equipment does not need to configure the database .
what ⾄ It can also be used for XML⽂ Piece in ⾏ Modify and return the result to the server . Imagine ⼀ Next ,⼀ The platform has mutual
United ⽹ Function and ⽀ a XML How will the refrigerator bring to the market ⼤ The impact of . You don't have to get up early to get it ⽜ milk
了 !

5. Preparation

Many should ⽤ The configuration data is stored in various ⽂ Pieces of ⾥,⽐ Such as .INI⽂ Pieces of . In spite of this ⽂ The file format has made
⽤ For many years and ⼀ Straight good ⽤, however XML Or better ⽅ The formula should be ⽤ Program mark configuration data . send ⽤. 
NET⾥ Class , Such as XmlDocument and XmlTextReader, Mark the configuration data as XML Format , Can make it more
Readability , And can ⽅ Conveniently integrated into the should ⽤ Go to... In the system . send ⽤XML Preparation ⽂ The piece should ⽤ The program can ⽅ Handle conveniently
Data needed , No ⽤ Like other should ⽤ In that way, it can only be modified and maintained after recompiling ⽤ System
 

The standard XML Format  

  1. There is and only one root element
  2. XML Labels are case sensitive
  3. Use the end tag correctly
  4. Nesting labels correctly
  5. Legal tag name used
  6. Define valid properties

Element definition

  Case study

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE persons[
<!ELEMENT persons (person+)>
<!ELEMENT person (name,age,contact,br?)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT contact (phone*,email?)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT br EMPTY>
]>
<persons>
	<person>
		<name> Zhang Xiaoming </name>
		<age>10</age>
		<contact>
			<phone>1234567</phone>
		</contact>
		<br/>
	</person>
	<person>
		<name> Zhang Daming </name>
		<age>35</age>
		<contact>
			<email>[email protected]</email>
		</contact>
	</person>
</persons>

Attribute definitions

  Case study

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE persons[
<!ELEMENT persons (person+)>
<!ELEMENT person (name,age,contact,br?)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT contact (phone*,email?)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT br EMPTY>
<!--  Attribute definitions -->
<!ATTLIST person
   pid ID #REQUIRED
   sex ( male | Woman ) ' male '
   qq CDATA #IMPLIED
   parent IDREF #IMPLIED
>
]>
<persons>
	<person pid="p1" sex=" male " qq="aaa" parent="p2">
		<name> Zhang Xiaoming </name>
		<age>10</age>
		<contact>
			<phone>1234567</phone>
		</contact>
		<br/>
	</person>
	<person pid="p2">
		<name> Zhang Daming </name>
		<age>35</age>
		<contact>
			<email>[email protected]</email>
		</contact>
	</person>
</persons>

This article ends here , Next

原网站

版权声明
本文为[16000 mu of roses that turn the world upside down]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060017183350.html