Home Backend Development XML/RSS Tutorial xml function and syntax

xml function and syntax

Feb 16, 2017 pm 03:43 PM

2 XML作用
		2.1 描述带关系的数据(软件的配置文件)
			web服务器(PC): 
			学生管理系统 -> 添加学生功能 -> 添加学生页面 -> name=eric&email=eric@qq.com  
				前提: 网络(IP地址: oracle:255.43.12.54  端口:1521 )

				java代码:使用ip(255.43.12.54)地址和端口(1521),连接oracle数据库,保存学生数据。

				把ip地址端口配置到xml文件:
						host.xml
							<host>
								<ip>255.43.12.55</ip>
								<port>1521</port>
							</host>

			数据库服务器(PC):
						主服务器(255.43.12.54):Oracle数据库软件(负载)
						副服务器(255.43.12.55):Oracle数据库软件
		2.2 数据的载体(小型的“数据库”)
			教师管理系统: 	姓名   工龄+1  邮箱 

			发教师数据给财务管理系统: 
					String teacher =    name=张三&email=zhangsan@qq.com&workage=2  字符串
							(问题: 1)不好解析 2)不是规范)

					teacher.xml
						<teacher>	
								<name>张三</name>
								<email>zhangsan@qq.com</email>
								<workage>2</workage>
						</teacher>
					这种一种规范

			财务管理系统:   
						姓名   工龄+1  邮箱
					发奖金:   统计奖金。   工龄
					发邮件功能: 
							邮箱   姓名   金额

			方案一: 在财务管理系统中维护了一套教师信息。
					每年 : 工龄增加  维护了两个系统的信息。

			方案二: 教师信息只在教学管理系统中维护。
3 XML语法
		xml文件以xml后缀名结尾。
		xml文件需要使用xml解析器去解析。浏览器内置了xml解析器。
		3.1 标签
			语法: <student></student>  开始标签  标签体内容  结束标签
				1)<student/> 或 <student></student> 空标签。没有标签体内容
				2)xml标签名称区分大小写。
				3)xml标签一定要正确配对。
				4)xml标签名中间不能使用空格
				5)xml标签名不能以数字开头
				6)注意: 在一个xml文档中,有且仅有一个根标签
		3.2 属性
			语法: <Student name="eric">student</Student>
			name:属性名。name="eric"属性值
			注意:
					1)属性值必须以引号包含,不能省略,也不能单双引号混用!!!
					2)【一个标签】内可以有多个属性,但不能出现重复的属性名!!!
		3.3 注释
					语言: <!--  xml注释 -->

		练习:
				通讯录系统
				联系人数据:编号 (唯一的) 姓名   年龄   电话 邮箱  QQ 

				 要求: 
				contact.xml
					1)设计一个xml文件,用于存储联系人数据
					2)这个xml文件可以存取多个联系人。
		3.4 文档声明
		语法: <?xml version="1.0" encoding="utf-8"?>

		version: xml的版本号
		encoding: 解析xml文件时查询的码表(解码过程时查询的码表),浏览器打开时候的编码方式

		注意:
				1)如果在ecplise工具中开发xml文件,保存xml文件时自动按照文档声明的encoding来保存文件。
				2)如果用记事本工具修改xml文件,注意【保存xml文件】按照文档声明的encoding的码表来保存。

		3.5 转义字符
		在xml中内置了一些特殊字符,这些特殊字符不能直接被浏览器原样输出。如果希望把这些特殊字符按照原样输出到浏览器,对这些特殊字符进行转义。
		转义之后的字符就叫转义字节。

			 	特殊字符  转义字符
				 <         <
				 >         >
				 "         "
				&         &
				空格      &nsbp;
				
		3.6 CDATA块
		作用: 可以让一些需要进行包含特殊字符的内容统一进行[原样输出]。
		<![CDATA[
		<itcast>
			<br/>
		</itcast>
	      ]]> 

		3.7 处理指令
			作用: 告诉xml解析如果解析xml文档
			
处理指令,简称PI (processing instruction)。处理指令用来指挥解析引擎如何解析XML文档内容。
例如,在XML文档中可以使用xml-stylesheet指令,通知XML解析引擎,应用css文件显示xml文档内容。	
<?xml-stylesheet type="text/css" href="1.css"?>
处理指令必须以“<?”作为开头,以“?>”作为结尾,XML声明语句就是最常见的一种处理指令。
Copy after login

The above is the content of xml function and syntax. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


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

Using Python to merge and deduplicate XML data Using Python to merge and deduplicate XML data Aug 07, 2023 am 11:33 AM

Using Python to merge and deduplicate XML data XML (eXtensibleMarkupLanguage) is a markup language used to store and transmit data. When processing XML data, sometimes we need to merge multiple XML files into one, or remove duplicate data. This article will introduce how to use Python to implement XML data merging and deduplication, and give corresponding code examples. 1. XML data merging When we have multiple XML files, we need to merge them

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

Filtering and sorting XML data using Python Filtering and sorting XML data using Python Aug 07, 2023 pm 04:17 PM

Implementing filtering and sorting of XML data using Python Introduction: XML is a commonly used data exchange format that stores data in the form of tags and attributes. When processing XML data, we often need to filter and sort the data. Python provides many useful tools and libraries to process XML data. This article will introduce how to use Python to filter and sort XML data. Reading the XML file Before we begin, we need to read the XML file. Python has many XML processing libraries,

Import XML data into database using PHP Import XML data into database using PHP Aug 07, 2023 am 09:58 AM

Importing XML data into the database using PHP Introduction: During development, we often need to import external data into the database for further processing and analysis. As a commonly used data exchange format, XML is often used to store and transmit structured data. This article will introduce how to use PHP to import XML data into a database. Step 1: Parse the XML file First, we need to parse the XML file and extract the required data. PHP provides several ways to parse XML, the most commonly used of which is using Simple

Python implements conversion between XML and JSON Python implements conversion between XML and JSON Aug 07, 2023 pm 07:10 PM

Python implements conversion between XML and JSON Introduction: In the daily development process, we often need to convert data between different formats. XML and JSON are common data exchange formats. In Python, we can use various libraries to convert between XML and JSON. This article will introduce several commonly used methods, with code examples. 1. To convert XML to JSON in Python, we can use the xml.etree.ElementTree module

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

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

See all articles