XML

What?

EXtensible Markup Language describe data

Features

Tree Structure

<root>
  <child>
    <subchild>.....</subchild>
  </child>
</root>

Syntax

Must have root element Elements must have a closing tag Elements Must be properly nested Attribute values must be quoted Tags are case Sensitive XML does not truncate multiple white-spaces in a document

Comments

<!-- This is a comment -->

Entity References

< ----- &lt;
> ----- &gt;
& ----- &amp;
' ------ &apos;
" ----- &quot;

Element

an element can contains:

Attribute

metadata should be stored as attribute data itself should be stored as element

Namespace

xmlns="namespaceURI"

Encoding

<?xml version="1.0" encoding="UTF-8"?>

XPath

XPath uses path expressions to select nodes or node-sets in an XML document.

selects all the title nodes with a price higher than 35:

/bookstore/book[price>35]/title

XSLT

EXtensible Stylesheet Language Transformation

used to manipulate and transform XML documents to HTML with CSS

Example

XQuery

XQuery is designed to query XML data

Example

doc("books.xml")/bookstore/book[price<30]
Fork me on GitHub