XML
XML
XML is extensible: XML allows you to create your own self-descriptive tags
or language, that suits your application.
XML carries the data, does not present it: XML allows you to store the data
irrespective of how it will be presented.
Code example
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1>Book List</h1>
<ul>
<xsl:for-each select="library/book">
<li><xsl:value-of select="title"/></li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML Attributes – Explained Simply
<plant>
<name>Rose</name>
<type>Flower</type>
</plant>
<plant>
<name>Green</name>
<type>Color</type>
</plant>
Example:
ID (Unique Identifier)
Example:
The type attribute can only have values from a predefined list (like
"Sedan", "SUV").
❌ Invalid:
Instead, use:
NO RULES(ahead few)
XML components
The diagram illustrates the syntax rules for writing different types of
markup and text in an XML document. It highlights five key
components:
o Example:
Needed
o Example:
o <book>
o <title>XML Guide</title>
o </book>
Case sensitive
o Example:
o <book category="technology">
o <title>XML Guide</title>
o </book>
o Example:
o <message>Hello, World!</message>
XML references help include special characters and additional text in an XML document.
Since certain characters (like <, >, &) have special meanings in XML, references ensure that
they are correctly interpreted as data rather than code.
1. Entity References
Entity Meaning
< < (Less than)
> > (Greater than)
& & (Ampersand)
" " (Double quote)
' ' (Single quote)
2. Character References
These use a numeric Unicode code for a character, starting with &# and ending with
;.
They are useful for special symbols and characters not present on a keyboard.
Example:
<message>Letter A: A</message>
Output:
Letter A: A
More Examples:
Conclusion:
XML references make documents readable, structured, and error-free by handling
reserved symbols and special characters effectively.
Note
Whitespace characters like blanks, tabs and line-breaks between XML-elements and between
the XML-attributes will be ignored.