XML Basics

zhaozj2021-02-16  139

. Before making / editing XML, lets first learn what it is That begins with understanding why XML is;? Why does it exist Basically, XML was created to serve as an easily usable, readable method to format information within an basic text file What. IT Does Is Allows You To Contain Information (TEXT / NUMBERS) IN A Hierars One Bit of File File FOR HOLDING MORE INFORMATION.

In fact, you can think of XML just as that, as a text write-out of a hierarchical file system. It is NOT a script and does NOT "do" anything. It just provides information in an outlined and logically laid out manner.

For More Information Beyond Laymens Terms, See: http://www.w3.org/xml/xml structurelooking at XML, You'll NOTML. IT Looks a Lot Like Html. In A Way HTML IS A TYPE OF XML WAS BUT THE STRUCTURE IN MANY CASES The Same. Here's A Simple Example of An XML File:

Sandy joseph i love you!

Its fairly easy to see what information this XML file holds and how its laid out. In the file folder metaphor, this represents a folder called LETTER which contains 3 other folders TO, FROM and BODY. Each one of those folders contains the given text. The folder TO for example has "Sandy" in it.The XML itself is made up primarily of 2 things, Nodes and Attributes. Each one of these are containers for information, though attributes are special in that they are contained only within nodes. in the example above, each one of the 'folders' (ie LETTER, TO, etc.) are a node. Nodes, as the name suggests, are containers which can hold textual information (in Attributes) as well as have within them other nodes as seen above. Its this encapsulation which makes up the hierarchy of a XML file defining its structure.There are no attributes in the LETTER XML example, and often attributes are not used at all. However, they can be useful in specifying properties or Little Tid-Bits of Information Withnin A Given node. here uses attributes: The Meeting Was Boring. I Made Paper Airplanes with a memo i recieved earlier.

MEETING, for example, contains the attribute TIME. TIME's value is 10:00. In HTML attributes would be like the href or target options within an anchor tag. TIME just gives you a way to specify some extra information which is associated directly with that node.The above example demonstrates two other things: Nodes with out any child nodes, or nodes within it, can be terminated within their own tag using /> instead of re-writing the tag over again in closing Tag. for esample, can be instead be written as . this is seen with the served and spnt nodes forin lunch. You can see how the text in the lunch node - "John Came over to talk to me He smells funny today "-... sits pleasantly with the other nodes SERVED and SPENT This is because that text is itself a node Its a text node It does not have any bracket tags nor any attributes or child.. Nodes (folders in itself). All it is is just text - ITS A TEXT NODE! The First Example Also Had Text Nodes. "Sandy", " Joseph "I Love You!" WERE All Text Nodes. Non-Text Nodes Can Also Be ReferRed To As "Elements".

Hopefully, for those of you who did not know anything or knew little about XML, this cleared some things up or gave you an idea on how to perceive XML. Feel free to post any questions you may have on the forums.

转载请注明原文地址:https://www.9cbs.com/read-8767.html

New Post(0)