Home > Article > Backend Development > Basic introduction to xml and xml tag elements for getting started with php operation xml
The example of this article describes the basic introduction of XML and XML tag elements for getting started with PHP operation of XML. Share it with everyone for your reference. The specific analysis is as follows:
Explain with xml examples:
<?xml version="1.0" encoding="utf-8" standalone="no" ?> <class> <student> <name>小乔</name> <sex>女</sex> <age>23</age> </student> <student> <name>周瑜</name> <sex>男</sex> <age>27</age> </student> </class>
1. xml statement:
b79fc610f7ce7b550ea0bc6e33a5363f
(1). The xml statement should be placed on the first line of the document;
(2) Encoding: document character encoding, such as utf-8, gb2312, etc.
(3), standalone: The value is yes or no, optional, indicating whether the document definition is independent, that is, whether it is related to other documents. The default is no.
2. Root element
The outermost 06fc722e8309f4fc3af5f9b05c0cd2860ec87398349fbf0e875b8223c9aec3c7 is the root element. Each xml document must have and can only have one root element.
3. xml elements/tags/nodes
52fc45c754660ae0425ccd0c640c83e62420879c57d5ec91aac5130013066cda, 8a11bc632ea32a57b3e3693c7987c420df406f776eecbaf16b62325323196f14, 5eb1976fb331069a3f8db095dc061fe91a8de34dd1983c867de2a59ae06cc634, ff4fd28be6111b38109cb452b13c2daaIf there is no content in the tag, such as there is no entity content between 8a11bc632ea32a57b3e3693c7987c420df406f776eecbaf16b62325323196f14, it can be abbreviated as 5c0917f69e6ca599fab58bb4b672da9f. Even if it is written as 8a11bc632ea32a57b3e3693c7987c420df406f776eecbaf16b62325323196f14, when the browser is opened, it will still display 5c0917f69e6ca599fab58bb4b672da9f
4. Spaces and line breaks in tags
Spaces and line breaks that appear in tags, the xml document will Spaces and newlines are treated as original content. So, pay special attention when programming.
5. Naming specifications for xml tags
(1) case-sensitive;
(2) cannot start with numbers or "_";
(3) cannot start with special characters such as xml, XML, Xml, etc.;
(4 ) cannot contain spaces;
(5) cannot contain colons.
I hope what is described in this article will be helpful to everyone’s php operation XML programming.
For more articles on the basic introduction to XML and XML tag elements for getting started with PHP operations, please pay attention to the PHP Chinese website!