MENU
XML
XML represents a way to store data. Although somewhat verbose, an XML document is both human-readable and machine-readable. It can be regarded as something intermediate between a text file and a structured SQL table.Whereas an SQL table is two-dimensional, an XML document is inherently hierarchical. While SQL operates at the server, XML is a client technology as much as a server technology. In general, SQL is best suited for highly dynamic data because of its storage efficiency, while XML is best suited for static content. Where significant advantages in retrieval efficiency, storage space, and security are required, SQL is more appropriate. XML data, however, can be easily prepared, transformed, and transported.
As an example, a Microsoft Word document (.docx) can be unzipped into a set of files, and XSLT can then be used to transform the resulting XML file into HTML. PDF files can likewise be converted to XML using the free online tool at https://onlineconvertfree.com/convert-format/pdf-to-xml/.
The following is an example of an XML document. Containing various tags and attributes, an XML document resembles an HTML document, except that the names of the XML tags and attributes are defined by the author.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<bookslist>
<book id="123321">
<title>Harry Potter</title>
<author>J. K. Rowling</author>
<ISBN>9780545010221</ISBN>
<price>22.90</price>
<bestseller/>
</book>
<book id="456654">
<title>Fantasy in Death</title>
<author>J. D. Robb</author>
<ISBN>9781101185360</ISBN>
<price>7.81</price>
</book>
</bookslist>- have a root element. In the example above, <bookslist> is the root element.
- close all elements. This means that for each opening tag <tag>, there must be a closing tag </tag>. Empty tags can be abbreviated as <tag/>.
- quote all attribute values. In the example above, id is an attribute of the <book> element, and its value (123321) must be quoted.
- be case-sensitive in tag names.
- escape special characters such as < and & when they are not markup. XML defines five built-in character entities: < (<), > (>), & (&), ' ('), " ("). Additional entities may be defined in a DTD.
- use hexadecimal references for any other Unicode character, such as &.
XML documents can be viewed directly in a browser. Dedicated XML editors such as Altova XMLSpy or OxygenXML are commonly used to process XML documents in various ways. A free Notepad++ plugin called XML Tools, available at http://sourceforge.net/projects/npp-plugins/files/XML%20Tools/, can be used to format XML documents, perform XSD validation, apply XSLT, and more.