- A computer language which use mark up and is capable to being extend.
- XML was designed to store and transport data
- Markup : Notation or Symbol used to correct in marking up text and indicate how text should be display (<, >, ^,?,/)
- Extensible : Capable to expend or add by Developer.
- XML Element
- Case Sensitive : Open and Close Tag but be same. E.g. <chap>
- Not overlap
- XML Document should have 1 root Element e.g. book
- XML attributes
- single or double quotation (' or ")
- Good for html
- XML Declaration (prolog)
- optional, but if has, it must 1st line and no other content.
- version + character encoding used in document
- version is mandatory and encoding is optional (Support UTF-8 or UTF-16.)
Avoid using XML attributes
- attributes cannot contain multiple values (child elements can).
- attributes are not easily expandable (for future changes).
- attributes cannot describe structures (child elements can).
- attributes are more difficult to manipulate by program code.
- attribute values are not easy to test against a DTD.
When use XML attributes and element
- Element is store part of the data, attribute is not (ID, counter or unique identifier)
- Element store data itself, attribute is store metadata.
XML VS HTML
- XML was designed to carry data - with focus on what data is.
- HTML was designed to display data - with focus on how data looks.
- XML tags are not predefined like HTML tags are.
- XML has rule, HTML no rule.
- newer version of HTML, strict rules.
- Consist 3 parts : DOCTYPE, Head and Body.
- All Tags closed
- <!DOCTYPE html> -is Document Type Definition (DTD), specifies what type of document is this (XHTML)
- <html xmlns="http://www.w3.org/1999/xhtml"> - specifies the namespace, tell browser all tags contained within <html> belong to CHTML namespace as definesd by the W3C
- <meta> tag is used to specify keywords that describe a document's contents (name & content)
- Example: <strong><p><br /><h1>
HTML
|
XHTML
|
No closing tag <br>
|
Tag are extensible <br />
|
Tags are not case-sensitive <Body>
|
Tags only allow lowercase <body>
|
Attribute optional be quoted <a href=index.html>
|
Attribute must be quoted <a href="index.html">
|
Overlapping tags <b><i></b></i>
|
No overlapping tags <b><i></i></b>
|
XPath
- Language for define parts of an XML document. It Is a major element in XSLT.
- uses path expression to navigate in XML.(allow condition)
- E.g. /bookstore/book[price>35]
- E.g. /root_tag/element_a/element_b
- Selection and addressing elements and attributes in an XML document. E.g. Select node
XSLT
- eXtensible Stylesheet Language
- Transformation of XML document into HTML, XHTML (become XHTML got tables or line that match with XML) E.g. people.xml + people.xls
- XPath identifies the parts of an XML document that should be transformed, and XSLT says how the transformation should be done
XML vs JSON vs CSV
YAML
Most easily understood as an extension of JSON. Has a notion of aliases that allow object graphs of arbitrary complexity to be created. Has a concept of metadata like tags that can be used for proper typing.
Advantages:
Disadvantages:
|
No comments:
Post a Comment