preface:
This is my summary. If there is anything wrong, please give me some advice. You can go to the rookie tutorial for self-study in detail.
Learn the front end from scratch - (II)
What is XML?
Quote the official answer:
XML refers to EXtensible Markup Language. XML is a markup language much like HTML.
XML is designed to transmit data, not display data. XML tags are not predefined. You need to define your own label. XML is designed to be self descriptive. XML is a W3C recommendation.
Having said so much, my summary of xml is a data format, similar to JSON format, which is also used to store data
for instance:
The first part is written in the format of "experience =" young "/ > and the second part is written in the format of" experience = "simple" / > XML
You can do the same
<person> <age value="too young" /> <experience value="too simple" /> <result value="sometimes naive" /> </person>
json is familiar:
{ "age":"too young", "experience":"too simple", "result":"sometimes naive" }
No, these three are just different data storage formats.
An XML error will terminate your program
Errors in the XML document will terminate your XML application.
W3C's XML specification states that if there is an error in the XML document, the program should not continue to process the document. The reason is that XML software should be lightweight, fast and have good compatibility.
If you use HTML, it is possible to create a document that contains a lot of errors (for example, you forget the end tag). One of the main reasons is that HTML browsers are quite bloated and have poor compatibility, and they have their own way to determine what the document should look like when an error is found.
When using XML, this situation should not exist, so when the development is completed, you can go to the rookie tutorial to verify, and the link will be put:
https://www.runoob.com/xml/xml-validator.html
XML naming rules
XML elements must follow the following naming rules:
Names can contain letters, numbers, and other characters
The name cannot start with a number or punctuation mark
The name cannot start with the letter Xml (or Xml, Xml, etc.)
The name cannot contain spaces
Basically the same. Different from other formats, it can be named by any name without reserved words.
Next is my knowledge blind spot. I don't mainly use xml, but I have to understand that, similar to json, js can call xml to store and browse data
XMLHttpRequest object
The XMLHttpRequest object is used to exchange data with the server in the background.
The XMLHttpRequest object is a developer's dream because you can:
Update the web page without reloading the page, request data from the server after the page has been loaded, receive data from the server after the page has been loaded, and send data to the server in the background
To learn more about the XMLHttpRequest object, please go to the rookie tutorial by yourself. After all, I don't understand it very well.
Here is a real column code for loading xml, which is not well understood yet
Come back and explain when I become a technical bull in the future:
<html> <body> <h1>W3Schools Internal Note</h1> <div> <b>To:</b> <span id="to"></span><br /> <b>From:</b> <span id="from"></span><br /> <b>Message:</b> <span id="message"></span> </div> <script> if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","note.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.getElementById("to").innerHTML= xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue; document.getElementById("from").innerHTML= xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue; document.getElementById("message").innerHTML= xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue; </script> </body> </html>
Finally, if the summary is not very good, comments are welcome!