XML Basics: Structure and Syntax Guide
XML Basics: Structure and Syntax Guide
Lecture Notes
(HTML), XML differs fundamentally in its purpose and flexibility. While HTML uses
predefined tags primarily for presenting information in web browsers, XML allows users
to define their own tags, making it a meta-language capable of defining other
specialized markup languages. Examples of XML-based languages include XHTML,
1
MathML, SVG, RSS, and RDF. Its primary function is not presentation but rather the
3
powerful tool for storing, searching, and, crucially, sharing data across different systems
and platforms. Because the fundamental syntax is standardized by the W3C , systems
3 2
can exchange XML data reliably, knowing that the recipient system will be able to parse
it correctly. This interoperability makes XML highly suitable for data interchange over
3
the internet, such as in web services where it can be used to structure requests and
responses. 1
XML documents adhere to a specific set of syntax rules, drawing parallels with HTML
but with stricter enforcement. 3
1
• Elements: The fundamental building blocks are elements, marked by start tags
(e.g., <book>) and end tags (e.g., </book>). The content resides between these
tags. Elements can be nested hierarchically to represent data relationships. Empty
3 3
elements, which have no content, can use a self-closing tag format (e.g.,
<image/>). 3
• Attributes: Elements can possess attributes within their start tag to provide
additional metadata. Attributes consist of a name-value pair, with the value
enclosed in quotes (single or double). For example: <book category="fiction">.
3
• Root Element: Every XML document must contain exactly one top-level element,
known as the root element, which encloses all other elements. 3
• XML Declaration (Prolog): While not strictly mandatory in all contexts, XML
documents typically begin with an XML declaration, specifying the XML version and
character encoding. Example: <?xml version="1.0" encoding="UTF-8"?>. This is
3
• Case Sensitivity: Unlike HTML, XML is case-sensitive. Start and end tags must
match exactly in case (e.g., <Book> is different from <book>). 3
relationships are clearly defined. It is easily queried using languages like SQL.
14 14
2
• Semi-structured Data: This category falls between structured and unstructured
data. It does not conform to the strict tabular structure of relational databases but
6
different attributes. 6
o Self-Descriptive: Often includes tags or metadata within the data itself (like XML
tags or JSON key-value pairs) that provide context about the content and
structure. 6
XML is a prime example of semi-structured data. Its use of tags provides organization
6
and self-description, making it more structured than plain text. However, its flexibility in
defining tags and structures means it doesn't adhere to the rigid schema requirements
of traditional structured data found in RDBMS. This flexibility makes XML suitable for
10
exchanging diverse data on the internet and representing data where the structure
might vary or evolve. 6
The rise of semi-structured data, driven by web applications, APIs, mobile devices, and
IoT, necessitates data platforms capable of handling both structured and semi-
structured formats effectively for business intelligence and analytics. 11
1. Single Root Element: The document must contain exactly one root element.3
2. Matching Tags: Every start tag must have a corresponding end tag, or the element
must be written using the self-closing tag syntax. 3
3
4. Attribute Values Quoted: All attribute values must be enclosed in either single or
double quotes. 3
5. Case Sensitivity: Element and attribute names are case-sensitive; start and end
tags must match case. 3
6. Special Characters: Reserved characters like <, >, &, ", ' must be escaped using
their corresponding entity references (<, >, &, ", ') when used within element
content or attribute values, unless they are part of markup itself. 3
A document that fails any of these rules is not well-formed and will typically cause an
error during parsing. Well-formedness is the baseline requirement for any XML
3
document. Further validation against a schema (like DTD or XSD) checks for structural
and content validity, which is discussed in Module 2. 3
XML
<from>Jani</from>
<heading>Reminder</heading>
Description: This document represents a simple note. <note> is the root element,
containing child elements <to>, <from>, <heading>, and <body>, each holding text
content. It includes an XML declaration. 3
4
Example 2: A Book Representation
XML
<publisher>Pan Books</publisher>
</book>
Description: This document describes a book. <book> is the root element and includes
attributes category and isbn. It contains child elements like <title> (which itself has a
lang attribute), <author>, <year>, and <publisher>. 4
XML
Description: This example shows an empty element <instock> using the self-closing tag
syntax. It also includes an attribute available. 3
5
These examples illustrate the basic structure, nesting, attributes, and text content
common in XML documents.
XML's design principle of separating data structure and content from presentation
(unlike HTML, which mixes them ) is a cornerstone of its utility. This separation allows
1
the same XML data source to be presented in multiple ways (e.g., styled with CSS for
web display , transformed with XSLT into HTML or PDF , or processed by backend
3 3
applications) without altering the underlying data. This promotes data reusability and
simplifies maintenance, as changes to presentation logic do not require changes to the
data structure itself.
a level of predictability and reliability when exchanging data between systems. While
potentially perceived as less forgiving than HTML's error handling , this strictness is
19
crucial for data integrity and automated processing, forming the foundation upon which
more complex validation mechanisms (DTDs, XSDs) are built.
6
7. Ensure the document is well-formed (correct nesting, closing tags, quoted
attributes).
XML
<name>Alice Wonderland</name>
<email>alice@[Link]</email>
<phone type="mobile">123-456-7890</phone>
</contact>
<contact id="c002">
<phone type="work">987-654-3210</phone>
<phone type="mobile">555-555-5555</phone>
</contact>
</contacts>
ensure that the document follows a specific structure or uses appropriate content for a
particular application.
7
This leads to the concept of a valid XML document. A valid XML document is one that is
not only well-formed but also conforms to the rules defined by a specific schema, such
as a Document Type Definition (DTD) or an XML Schema Definition (XSD). These 3
schemas define the legal building blocks of an XML document: the allowed elements,
attributes, their order, nesting, data types (more so in XSD), and occurrences. 9
Validation ensures that the XML data is structured consistently and correctly according
to predefined business rules or data exchange agreements. 23
DTDs represent an older, established mechanism for defining the structure of an XML
document, originating from SGML. They define the legal elements, attributes, and their
22
arrangement. 9
• Linking DTD to XML: A DTD is associated with an XML document via the
<!DOCTYPE> declaration, placed after the XML declaration. 9
o Internal DTD: Declarations are embedded directly within the XML file inside
square brackets [...] in the DOCTYPE declaration. 9
8
o <!ATTLIST element-name attr-name attr-type default-decl>: Defines
attributes for a given element. 9
expansion, particularly with external entities, can be exploited in attacks like the
"Billion Laughs" attack, a denial-of-service vulnerability. 28
<name>Alice Wonderland</name>
<email>alice@[Link]</email>
<phone type="mobile">123-456-7890</phone>
</contact>
<contact id="c002">
<phone type="work">987-654-3210</phone>
<phone type="mobile">555-555-5555</phone>
</contact>
</contacts>
9
(Syntax based on ) 9
• Validation Example: The XML above, including the first two <contact> elements, is
valid against the internal DTD. An XML validator would confirm this. If the third
(commented out) <contact> element were included, the document would become
invalid because it lacks the required id attribute as defined by <!ATTLIST contact id
CDATA #REQUIRED>. Similarly, using a phone type other than "mobile", "work", or
"home" would cause invalidity. 3
capabilities are very weak, mostly treating content as strings (#PCDATA). The22
syntax is not XML-based, requiring separate parsing logic. They offer less control
23
over cardinality and structure compared to XSD. DTDs are generally considered
23
XML Schema Definition (XSD), also known as XML Schema, is the W3C-recommended
standard for defining the structure, content, and data types of XML documents. It 9
overcomes many limitations of DTDs and provides a much richer and more precise way
to model XML data. 23
• Purpose: To describe the structure and constrain the content of XML documents,
including detailed data typing and namespace support. 23
10
o XML-Based Syntax: XSD schemas are themselves written in XML, making them
processable by standard XML tools and potentially easier for XML developers
to learn and integrate. 9
o Extensibility: More extensible and provides greater control over XML structure
and content rules. 23
▪ type: The data type of the element (e.g., xs:string, xs:integer, or a custom
type name). 9
include:
11
▪ name: The name of the attribute.
▪ type: The data type of the attribute.
▪ use: Specifies if the attribute is required, optional (default), or prohibited.
▪ default: Provides a default value.
▪ fixed: Provides a fixed value that cannot be changed in the instance.
o <xs:simpleType name="...">: Defines a simple type (text-only content, possibly
with attributes via <xs:simpleContent>). Often used with <xs:restriction> to
constrain built-in types (e.g., using <xs:pattern>, <xs:minLength>,
<xs:maxLength>, <xs:enumeration>). 20
<xs:element name="contacts">
<xs:complexType>
12
<xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="ContactType">
<xs:sequence>
</xs:complexType>
<xs:complexType name="PhoneType">
<xs:simpleContent>
<xs:extension base="xs:string">
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="PhoneCategoryType">
<xs:restriction base="xs:string">
<xs:enumeration value="mobile"/>
<xs:enumeration value="work"/>
<xs:enumeration value="home"/>
</xs:restriction>
</xs:simpleType>
13
<xs:simpleType name="EmailType">
<xs:restriction base="xs:string">
<xs:pattern value=".+@.+\..+"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
• Linking XSD to XML: The instance XML document uses attributes from the XML
Schema Instance namespace (xsi, typically [Link]
instance) to link to the schema. 30
o Declare the target namespace (often as the default namespace using xmlns).
o Declare the xsi namespace prefix.
o Use xsi:schemaLocation="namespaceURI schemaURL" to map the target
namespace URI to the location of the XSD file.
XML
<?xml version="1.0" encoding="UTF-8"?>
<contacts xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link] [Link]">
<contact id="c001">
<name>Alice Wonderland</name>
<email>alice@[Link]</email> <phone type="mobile">123-456-7890</phone>
</contact>
<contact id="c002">
14
• Validation Example: When validating the above XML against [Link], the
first <contact> element would be valid. The second <contact> element would be
invalid due to two errors: the email format doesn't match the EmailType pattern,
and the phone type "cell" is not one of the allowed values ("mobile", "work", "home")
defined in PhoneCategoryType. Validators (online tools, IDEs, libraries like lxml in
20
The choice between DTD and XSD depends on the complexity and requirements of the
XML application. While DTDs are simpler for basic structural validation, XSDs offer
significantly more power and flexibility, particularly for data-oriented applications
requiring type checking and namespace support. The following table summarizes the
key differences:
Data Types Very limited (mostly Rich built-in types (string, number,
#PCDATA/string) 22 date, etc.) + custom types 22
Validation Power Basic structure, element order, Structure, types, patterns, ranges,
attributes uniqueness, keys/keyrefs 23
Readability/Maintainability Can be compact but less XML syntax can be verbose but
readable for complex schemas potentially more readable 26
Complexity Simpler for basic tasks 23 More complex due to richer feature
set 23
15
Tooling Support Widely supported by older tools Excellent support in modern XML
29
tools, parsers, IDEs 28
Inline Declaration Can be embedded within the Typically external (.xsd file), linked
XML file 22 via xsi:schemaLocation 27
themselves XML documents, the same tools and programming libraries used to parse,
manipulate, and generate XML data can also be used to work with the schemas
themselves. This self-describing nature facilitates automated schema processing,
27
generation of documentation, code generation based on schemas (as seen with JAXB
), and easier validation of the schema documents themselves. This contrasts sharply
36
with DTDs, which require specialized parsers distinct from standard XML parsers. 27
uniquely identify elements and attributes based on their associated namespace URI,
preventing ambiguity and enabling the creation of modular, reusable, and interoperable
schemas essential for complex systems.
However, the increased power and expressiveness of XSD came at the cost of
complexity. The XSD specification is considerably larger and more intricate than the
23
16
DTD specification. This complexity led some developers to seek simpler or different
approaches to schema definition, contributing to the development and adoption of
alternative schema languages like Relax NG and Schematron. These alternatives often
24
focus on different validation aspects or offer simpler syntax, suggesting that while XSD
became the dominant standard, the quest for the optimal balance between expressive
power and usability in schema languages continued. This reflects a common pattern in
technology evolution where powerful, comprehensive solutions may sometimes be
perceived as overly complex for specific needs, leading to the emergence of more
focused or streamlined alternatives.
17
validate [Link] first against the DTD (if created) and then against the XSD.
Introduce deliberate errors (e.g., incorrect phone type, malformed email, missing
required attribute) and observe the validation failures reported by the tool.
• Concept: CSS rules can be applied to XML elements to control their visual
rendering (fonts, colors, spacing, layout) when displayed in a compatible browser. 3
The browser parses the XML and applies the associated CSS rules.
• Linking CSS to XML: The standard mechanism is the xml-stylesheet processing
instruction, placed in the XML document's prolog (after the XML declaration). 3
o Type Selectors: Target elements by their tag name (e.g., book, title, author).
Remember XML is case-sensitive.
o Attribute Selectors: Target elements based on their attributes (e.g.,
book[category="fiction"], phone[type="mobile"]).
o ID and Class Selectors: Can be used if the XML attributes id and class are
present (e.g., #summary, .important).
o Descendant, Child, Sibling Selectors: (, >, +, ~) work as they do in HTML.
18
• Display Properties: A crucial difference from HTML is that XML elements
generally have no default display semantics in the browser. Therefore, CSS rules
for XML often need to explicitly set the display property (e.g., display: block;,
display: inline;, display: table-cell;) to control layout. 42
• Example:
o XML ([Link]):
XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="report_style.css"?>
<report>
<title>Annual Sales Report</title>
<section id="summary">
<heading>Executive Summary</heading>
<paragraph>Overall sales demonstrated a significant increase of
<emphasis>15%</emphasis> compared to the previous fiscal year.</paragraph>
</section>
<section id="details">
<heading>Detailed Analysis</heading>
<paragraph>Region North experienced exceptional growth, exceeding targets
by 25%.</paragraph>
<paragraph>Region South showed steady performance but requires strategic
focus for improvement.</paragraph>
<item_list>
<item>Product A: +20%</item>
<item>Product B: +5%</item>
</item_list>
</section>
</report>
o CSS (report_style.css):
CSS
19
/* Basic document styling */
report {
display: block; /* Treat root like a block */
font-family: Verdana, Geneva, sans-serif;
margin: 2em;
background-color: #f8f8f8;
/* Title styling */
title {
display: block; /* Make title a block */
font-size: 2em;
font-weight: bold;
color: #2a2a7e;
margin-bottom: 1em;
text-align: center;
border-bottom: 2px solid #2a2a7e;
padding-bottom: 0.5em;
/* Section styling */
section {
display: block; /* Make sections blocks */
margin-bottom: 1.5em;
padding: 1em;
20
background-color: #eef; /* Light blue background for summary */
/* Heading styling */
heading {
display: block; /* Make headings blocks */
font-size: 1.4em;
font-weight: bold;
color: #333;
margin-bottom: 0.7em;
/* Paragraph styling */
paragraph {
display: block; /* Make paragraphs blocks */
margin-bottom: 0.5em;
line-height: 1.5;
/* Emphasis styling */
emphasis {
font-style: italic;
color: #006400; /* Dark green */
font-weight: bold;
}
margin-left: 2em;
21
item {
display: list-item; /* Render as list items */
list-style-type: square;
margin-bottom: 0.3em;
• Concept: An XSLT processor takes two inputs: the source XML document and an
XSLT stylesheet (itself an XML document). It processes the source tree based on
rules (templates) defined in the stylesheet and generates a result tree. The original
18
22
o Combine data from multiple XML sources (using the document() function ). 50
o Generate completely different output formats (e.g., transforming XML data into
an HTML webpage). 3
• Stylesheet Structure:
o XML Document: An XSLT stylesheet must be a well-formed XML document. 44
XSLT relies heavily on XPath to select nodes from the source XML tree for processing. 44
23
o <xsl:template match="xpath-pattern">: Defines a processing rule for nodes
matching the pattern. The pattern / matches the root of the entire document. 42
24
o Literal Result Elements (LREs): Any element in the stylesheet that is not in the
XSLT namespace (i.e., doesn't have the xsl: prefix) is treated as a literal result
element. It is copied directly to the output tree. Attributes on LREs are also
copied, and attribute value templates (using {xpath-expression} within attribute
values) allow dynamic computation of attribute values. Example: <p
18
class="{$category}">...</p>.
<name>Alice Wonderland</name>
<email>alice@[Link]</email>
<phone type="mobile">123-456-7890</phone>
</contact>
<contact id="c002">
<phone type="work">987-654-3210</phone>
<phone type="mobile">555-555-5555</phone>
</contact>
</contacts>
• XSLT (contacts_to_html.xsl):
XML
<xsl:stylesheet version="1.0" xmlns:xsl="[Link]
25
<xsl:template match="/">
<html>
<head>
<title>Contact List</title>
<style>
table, th, td { border: 1px solid black; border-collapse: collapse; padding: 5px; }
th { background-color: #f2f2f2; }
ul { list-style-type: none; margin: 0; padding: 0; }
</style>
</head>
<body>
<h1>Contacts</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone Numbers</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="/contacts/contact"/>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="contact">
<tr>
26
<td><xsl:value-of select="@id"/></td>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="email"/></td>
<td>
<ul>
<xsl:apply-templates select="phone"/>
</ul>
</td>
</tr>
</xsl:template>
<xsl:template match="phone">
<li>
<xsl:value-of select="."/>
(<xsl:value-of select="@type"/>)
</li>
</xsl:template>
</xsl:stylesheet>
27
<h1>Contacts</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone Numbers</th>
</tr>
</thead>
<tbody>
<tr>
<td>c001</td>
<td>Alice Wonderland</td>
<td>alice@[Link]</td>
<td>
<ul>
<li>123-456-7890 (mobile)</li>
</ul>
</td>
</tr>
<tr>
<td>c002</td>
<td>
<ul>
<li>987-654-3210 (work)</li>
<li>555-555-5555 (mobile)</li>
</ul>
</td>
28
</tr>
</tbody>
</table>
</body>
</html>
This HTML, generated by the XSLT processor, can be directly rendered by any web
browser.
The contrast between CSS and XSLT for XML presentation highlights a fundamental
difference in approach. CSS acts as a non-invasive layer, applying display rules to the
existing XML structure primarily for browser rendering. It modifies how the data looks.
3
what content it contains. This transformative power makes XSLT far more versatile for
complex presentation scenarios where the desired output structure differs significantly
from the source XML structure, or where data manipulation is required before display.
CSS is simpler for direct styling when the XML structure closely matches the desired
display layout.
The integral role of XPath within XSLT underscores XPath's significance as more than
just a standalone query language. It serves as the essential mechanism for selecting
44
nodes within the source document that XSLT templates will process (match attribute)
and for extracting data or selecting further nodes for processing within those templates
(select attribute in elements like <xsl:value-of>, <xsl:apply-templates>, <xsl:for-each>).
This deep integration means that proficiency in XPath is a prerequisite for effective
XSLT development. Furthermore, XPath's utility extends beyond XSLT, being crucial for
programmatic DOM navigation and forming the basis for XQuery , positioning it as a
51 55
29
3.6 Practical Idea: Create CSS/XSLT for Contacts XML
1. CSS Styling:
o Create a CSS file ([Link]).
o Write CSS rules to style the contacts, contact, name, email, and phone elements
for clear display in a browser. For example:
▪ Make each contact a block with a border and margin.
▪ Style the name element prominently (e.g., larger font, bold).
▪ Display email and phone elements clearly, perhaps using pseudo-elements
(::before) to add labels like "Email: " or "Phone: ".
▪ Style phone numbers differently based on their type attribute using attribute
selectors (e.g., phone[type="mobile"] { color: green; }).
o Link this CSS file to [Link] using <?xml-stylesheet?>.
o Open [Link] in a browser (using a local web server if needed) to view the
styled output.
2. XSLT Transformation:
o Create an XSLT file (contacts_to_html.xsl) similar to the example in section 3.4.
o Ensure it transforms the [Link] data into a well-structured HTML page
(e.g., using an HTML table or a definition list <dl>).
o Include columns/sections for ID, Name, Email, and Phone(s) with type.
o Link this XSLT file to [Link] using <?xml-stylesheet?> (replacing the CSS
link).
o Open [Link] in a browser to view the generated HTML output.
3. Comparison: Compare the visual results and the development process. Note
the differences in control over structure and content between the CSS and XSLT
approaches. Discuss which approach might be better suited depending on whether
the goal is simple styling versus significant restructuring for presentation.
30
Beyond the core XML specification, DTDs, XSDs, CSS, and XSLT, several other related
standards and technologies are important within the broader XML ecosystem. This
module focuses on XHTML and the Document Object Model (DOM).
XHTML emerged as an effort by the W3C to bridge the gap between the widespread
use of HTML and the stricter syntax requirements of XML. 19
that was well-formed XML, making it more suitable for automated processing and
integration with other XML technologies. 58
• Relationship to HTML & XML: It uses the familiar vocabulary (tags and attributes)
of HTML but enforces XML's stricter syntax rules. It was intended to be the
19
group continued developing HTML, leading to HTML5, which became the dominant
standard. HTML5 itself is designed to be backward-compatible and handle much
59
of the markup previously considered XHTML, although its parsing rules are more
lenient than XML's. The term "XHTML" is now less frequently used to describe the
60
31
• MIME Type and Parsing: The critical factor determining how a document is
processed is the MIME type sent by the server. 19
syntax on the web are served this way, effectively making them invalid HTML
processed with HTML rules. 19
prevent rendering. This MIME type caused issues with older browsers (notably
Internet Explorer) that did not support it properly. 19
While the push for XHTML as the primary web standard waned with the rise of HTML5,
understanding its principles remains valuable as it represents the application of XML's
rigor to web documents and influenced the design of HTML5.
The Document Object Model (DOM) is a crucial standard for interacting with structured
documents like HTML and XML programmatically.
• Purpose: It provides a standard way for programs and scripts (most commonly
JavaScript in web browsers) to dynamically access, traverse, and manipulate the
content, structure, and style of documents. Essentially, the DOM connects the
54
o Nodes: The fundamental units (Element, Attr, Text, Comment, Document, etc.). 64
32
o Relationships: Nodes have relationships like parent, child, sibling, ancestor,
descendant. 54
o Root Node: The top-level node representing the entire document (e.g., the
Document node itself, or the <html> element in HTML). 54
languages, including Python , Java , Perl, and others. W3C and WHATWG
63 36 64
o Node: The base interface from which most other DOM interfaces inherit.
Provides fundamental properties like nodeName, nodeValue, nodeType,
parentNode, childNodes, firstChild, lastChild, textContent, and methods like
appendChild(), removeChild(), insertBefore(), cloneNode(). 54
o Element: Represents an element node (e.g., <book>, <p>). Inherits from Node.
Provides element-specific methods like getAttribute(), setAttribute(),
removeAttribute(), getElementsByTagName() (scoped to the element). 54
o Text: Represents the textual content within an element or attribute. Inherits from
64
like length.
33
4.3 DOM Access and Manipulation Example (JavaScript)
The following example demonstrates basic DOM manipulation using JavaScript within
an HTML page. The same principles apply when working with an XML document parsed
into a DOM structure using tools like DOMParser.
HTML (dom_example.html):
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<p>First item.</p>
<p>Second item.</p>
</div>
<script>
// --- DOM Manipulation Script ---
// 1. Selecting Elements
const introPara = [Link]('intro');
const contentDiv = [Link]('#content'); // Using CSS selector
const allParas = [Link]('p');
const changeButton = [Link]('changeBtn');
const addButton = [Link]('addBtn');
34
// Function to run on button click
function modifyContent() {
// 2. Accessing/Modifying Text Content
[Link] = "Introduction paragraph has been updated!";
// 3. Accessing/Modifying Attributes
[Link]('data-status', 'updated');
[Link]("Intro para status:", [Link]('data-status'));
// 4. Changing Styles
if ([Link] > 1) {
allParas.[1][Link] = 'blue';
allParas.[1][Link] = 'bold';
}
// 6. Adding Elements
[Link](newPara);
// Example: Removing the first paragraph inside the div (if it exists)
const firstItem = [Link]('p');
if (firstItem && [Link] > 1) {
// [Link](firstItem); // Uncomment to enable removal
// [Link]("Removed first item.");
}
}
35
// Attach event listeners to buttons
[Link]('click', modifyContent);
[Link]('click', addItem);
</script>
</body>
</html>
JavaScript
let id = [Link]('id');
let nameElement = [Link]('name'); // Get first <name> child
let name = nameElement? [Link] : 'N/A'; // Access text content safely
let emailElement = [Link]('email');
let email = emailElement? [Link] : 'N/A';
// Modify an attribute
[Link]('status', 'processed');
[Link](` Set status to: ${[Link]('status')}`);
36
// Add a new 'last_updated' element
This illustrates how the standard DOM API provides a consistent way to interact with the
structure of both HTML and XML documents once they are loaded into memory.
The Document Object Model provides a critical abstraction layer, transforming a static
text-based markup document (HTML or XML) into a dynamic, in-memory object
representation. This object-oriented perspective is fundamental because it exposes the
63
37
The DOM standard encompasses both generic interfaces applicable to any XML
document (like Node, Element, Document) and more specialized interfaces for HTML
(like HTMLElement, HTMLInputElement). This layered design reflects the dual role of
63
browsers in handling both generic XML and the specific semantics of HTML. It allows
developers to use common, fundamental DOM manipulation techniques across both
types of documents (leveraging the generic interfaces), while still providing access to
HTML-specific properties and methods when needed. This promotes consistency and
64
code reuse, as the basic principles of node traversal, creation, and modification apply
broadly, regardless of whether the underlying document is a generic XML data file or a
rich HTML web page.
Task: Create a simple web page (xml_loader.html) that demonstrates loading and
displaying data from an XML file using JavaScript and the DOM.
▪ Selects the <ul> element where results will be displayed. Clears any
previous content from it.
▪ Uses DOM methods (getElementsByTagName, getAttribute, textContent) to
iterate through the <contact> elements in the parsed xmlDoc. 63
38
▪ For each contact, extract the id, name, and email.
▪ Creates a new HTML <li> element ([Link]('li')).
▪ Sets the textContent of the <li> to display the extracted contact information
(e.g., ID: c001, Name: Alice Wonderland, Email: alice@[Link]).
▪ Appends the newly created <li> element to the results <ul> using
appendChild.
o Include basic error handling (e.g., for fetch errors or parsing errors).
Two primary models dominate XML parsing: the Document Object Model (DOM) and
the Simple API for XML (SAX).
• DOM Parsing:
o Mechanism: The parser reads the entire XML document and constructs a
complete, hierarchical tree representation of the document in memory. Each36
element, attribute, and text segment becomes a node object in this tree.
o Advantages:
▪ Random Access: Allows navigation throughout the entire document tree in
any direction (parent, child, sibling) and modification of any node after
parsing is complete. 36
▪ Simpler Logic (for some tasks): Easier to implement logic that requires
knowledge of the document's overall structure or involves complex
structural manipulations.
o Disadvantages:
39
▪ Memory Intensive: Requires loading the entire document structure into
memory, making it unsuitable for very large XML files that exceed available
RAM. 69
▪ Initial Latency: Can have a higher startup time as the entire document
must be read and parsed before processing can begin. 71
• SAX Parsing:
o Mechanism: SAX is an event-driven, sequential access parser. The parser
36
o Advantages:
▪ Memory Efficient: Processes the XML document in a stream, requiring
very little memory regardless of the document size. Ideal for huge files. 33
▪ Fast Startup: Processing can begin as soon as the parser starts reading
the document.
o Disadvantages:
▪ Forward-Only: Cannot navigate backward or randomly access parts of the
document that have already been processed. 70
o Iterative Parsing: Libraries like Python's ElementTree and lxml offer iterparse
functions. This approach combines aspects of SAX and DOM. It parses the
8
40
document incrementally like SAX but can yield partial element trees as they are
completed. Crucially, it allows the application to process an element and then
discard it ([Link]()) to free up memory, providing a balance between ease
of use and memory efficiency for large files. 35
The choice between DOM and SAX (or related streaming/iterative methods) hinges on
the specific requirements: DOM is often preferred for smaller documents or when
random access and modification are needed, while SAX or iterative parsing is
necessary for large documents where memory consumption is a primary concern. This 70
• Libraries:
o [Link] (ET): A built-in module providing a simple, lightweight,
and "Pythonic" API for parsing and creating XML. Good for basic XML tasks.
4
o lxml: A powerful third-party library (requires installation: pip install lxml) built on
top of the C libraries libxml2 and libxslt. Generally faster and more feature-rich
78
than ElementTree. Offers excellent support for XPath 1.0, CSS selectors,
71
API and iterparse. Often the recommended choice for complex XML processing
4
or performance-critical applications.
o [Link]: A built-in module providing a W3C DOM Level 1
implementation. Parses the entire document into a DOM tree. Generally more
35
41
• ElementTree Parsing Example:
Python
import [Link] as ET
try:
tree = [Link]('[Link]')
root = [Link]() # Get the root <contacts> element
# xml_string = "<contacts>...</contacts>"
# root = [Link](xml_string)
42
except FileNotFoundError:
print("Error: [Link] not found.")
except [Link] as e:
print(f"Error parsing XML: {e}")
try:
tree = [Link]('[Link]')
root = [Link]()
# root = [Link](xml_string)
# contacts = [Link]("//contact[@id='c001']")
phones = [Link]('./phone')
for phone in phones:
phone_number = [Link]('./text()')
phone_type = [Link]('@type')
print(f" Phone: {phone_number} (Type: {phone_type})")
except FileNotFoundError:
print("Error: [Link] not found.")
except [Link] as e: # lxml specific parse error
print(f"Error parsing XML: {e}")
Both ElementTree and lxml provide convenient ways to construct XML structures
programmatically.
44
root = [Link]('orders')
[Link]('xmlns', '[Link] # Example namespace
45
print("Note: [Link] requires Python 3.9+ for pretty printing.")
46
item2 = [Link](order2, "{[Link] itemId='i60')
[Link] = 'Keyboard'
The Java API for XML Processing (JAXP) is the standard Java API for handling XML,
supporting DOM, SAX, StAX, and XSLT transformations. It provides an abstraction
70
47
Java
import [Link].*;
import [Link].*;
import [Link];
DocumentBuilderFactory dbFactory =
[Link]();
DocumentBuilder dBuilder = [Link]();
// Optional: Normalize the tree (merges adjacent text nodes, removes empty ones)
[Link]().normalize();
48
if ([Link]() == Node.ELEMENT_NODE) {
Element contactElement = (Element) contactNode;
// 5. Access Attributes
String id = [Link]("id");
String name =
[Link]("name").item(0).getTextContent();
String email =
[Link]("email").item(0).getTextContent();
NodeList phoneList =
[Link]("phone");
for (int j = 0; j < [Link](); j++) {
Element phoneElement = (Element) [Link](j);
String number = [Link]();
String type = [Link]("type");
[Link](" Phone: %s (Type: %s)%n", number, type);
}
}
}
} catch (Exception e) {
[Link](); // Handle parsing/IO exceptions
}
}
49
}
Java
import [Link].*;
import [Link].*;
import [Link];
import [Link];
[Link](inputFile, handler);
} catch (Exception e) {
[Link](); // Handle parsing/IO exceptions
}
}
}
50
// 4. Custom Handler extending DefaultHandler
class ContactHandler extends DefaultHandler {
@Override
[Link]("Parsing started...");
}
@Override
[Link]("Parsing finished.");
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws
SAXException {
if ([Link]("contact")) {
currentContactId = [Link]("id"); // Get attribute value
[Link]("\nStart Contact (ID: %s)%n", currentContactId);
} else if ([Link]("name")) {
51
bName = true;
} else if ([Link]("email")) {
bEmail = true;
} else if ([Link]("phone")) {
bPhone = true;
currentPhoneType = [Link]("type"); // Get phone type attribute
}
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (bName) {
[Link](" Name: " + [Link]());
bName = false;
} else if (bEmail) {
[Link](" Email: " + [Link]());
bEmail = false;
} else if (bPhone) {
[Link](" Phone: %s (Type: %s)%n", [Link](),
currentPhoneType);
bPhone = false;
currentPhoneType = null; // Reset phone type
}
if ([Link]("contact")) {
[Link]("End Contact");
currentContactId = null; // Reset contact ID
}
}
@Override
52
public void characters(char ch, int start, int length) throws SAXException {
@Override
@Override
@Override
Java offers several ways to generate XML, including using the DOM API or higher-level
libraries like JAXB.
Java
53
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link].*;
import [Link];
DocumentBuilderFactory dbFactory =
[Link]();
DocumentBuilder dBuilder = [Link]();
54
// Create item element for order1
TransformerFactory transformerFactory =
[Link]();
Transformer transformer = [Link]();
[Link]([Link], "yes");
[Link]("{[Link] "2"); //
Optional: specific indent amount
55
[Link](source, result);
} catch (Exception e) {
[Link]();
}
}
}
3. Create Java Objects: Instantiate and populate these Java objects with the
data to be written to XML.
4. Create JAXBContext: Obtain a JAXBContext instance for the root
class(es) involved ([Link]([Link])). 36
56
5. Create Marshaller: Create a Marshaller object from the JAXBContext
([Link]()). 36
57
public static void main(String args) {
try {
// 1. Create Java Objects
[Link](Marshaller.JAXB_FORMATTED_OUTPUT, true);
58
// 4. Marshal to XML File
} catch (JAXBException e) {
// Handle JAXB-specific exceptions
[Link]();
}
}
}
The availability of multiple parsing (DOM, SAX, StAX, iterparse) and generation (DOM,
JAXB, ElementTree/lxml) techniques within standard libraries or popular third-party
packages for languages like Python and Java underscores XML's maturity and
continued relevance as a data format. While newer formats like JSON have gained
35
popularity for specific use cases (especially web APIs), the robust tooling for XML
reflects its deep integration into enterprise systems, configuration management,
document markup, and established data exchange protocols. Libraries like lxml in
Python and JAXB in Java provide high-level abstractions that significantly simplify
common XML processing tasks for developers. They encapsulate much of the
8
59
memory efficiently (especially with large files), and troubleshooting issues that may
arise when using these higher-level tools. 35
1. Design XML Format: Define an XML structure for storing configuration settings.
For example:
XML
<configuration>
<database type="mysql">
<host>localhost</host>
<port>3306</port>
<username>user</username>
<password encrypted="false">pass123</password>
</database>
<api service="weather">
<url>[Link]
<key>your_api_key</key>
</api>
<ui>
<theme>dark</theme>
<fontSize>12</fontSize>
</ui>
</configuration>
2. Choose Language and Library: Select either Python (with ElementTree or lxml)
or Java (with JAXP DOM or JAXB).
3. Implement Reader: Write code to parse the [Link] file. Implement
functions/methods to:
o getSetting(xpath_or_key): Retrieves the value of a specific setting (e.g., get
database host, get weather API key). Using XPath can make this flexible.
60
o getSection(section_name): Retrieves all settings within a section (e.g., get all
database settings).
4. Implement Writer: Write code to modify the configuration data structure in
memory and save it back to [Link]. Implement functions/methods to:
o setSetting(xpath_or_key, value): Modifies an existing setting or adds a new one.
Handle creating parent elements if they don't exist.
o saveConfiguration(): Writes the current configuration state back to the XML file,
preserving the structure and potentially using pretty printing.
5. Testing: Create a sample [Link], run the program to read settings, modify a
few values (e.g., change the theme, update the password), add a new setting (e.g., a
new API key), and verify that the [Link] file is correctly updated upon saving.
Storing XML effectively requires balancing the need to preserve the document's
structure and semantics with the database's capabilities for efficient storage, querying,
and updating. The main challenges include handling XML's flexible schema, nested
structures, and potential for mixed content within the constraints of a chosen database
model. 72
61
relational tables (shredding), or using dedicated XML-specific data types (like
XMLType).
2. Native XML Databases (NXDs): Databases designed specifically to manage XML
documents as their fundamental data unit, often using an internal model based on
the XML structure itself (like DOM). 72
• CLOB/BLOB Storage:
o Concept: The simplest approach involves storing the entire XML document as
opaque data within a Character Large Object (CLOB) or Binary Large Object
(BLOB) column in a relational table. 72
o Cons: Highly inefficient for querying or updating specific parts of the XML
content, as the entire object must typically be retrieved and parsed by the
application or database functions for each operation. Performance degrades
72
significantly with document size. Indexing capabilities on the XML content itself
72
element might map to a Customers table, and its child <order> elements might
map to an Orders table with a foreign key linking back to Customers.
o Pros: Allows the use of standard SQL for querying the decomposed data;
leverages mature RDBMS features like indexing, transactions, and referential
integrity on the relational tables ; can be efficient for highly structured, data-
72
62
o Cons: The mapping process can be complex to design and implement ; loss of 72
the original XML document structure and hierarchy (DOM fidelity) is common ; 72
changes in the XML schema, as changes may require altering the relational
schema ; performs poorly for document-centric XML, deeply nested structures,
72
shredding. 87
annotation can still be complex for intricate XML structures ; while the logical
72
Native XML Databases are architected specifically for managing XML data.
63
• Concept: NXDs treat the XML document (or a logical fragment like a subtree
rooted at an element) as the fundamental unit of storage and retrieval. They72
operate directly on an XML data model, often conceptually similar to the DOM,
rather than mapping XML to a different model like relational tables. 72
• Pros:
o Natural Fit: Designed inherently for hierarchical, semi-structured XML data,
handling variations and complex nesting naturally. 84
o Fidelity: Preserve the full XML structure and hierarchy (DOM fidelity). 72
o Querying: Provide native, efficient support for XML query languages like XPath
and XQuery. Querying based on document structure is typically very efficient.
82 72
• Cons:
o Maturity/Features: May lag behind top-tier RDBMS in certain enterprise features
like transaction models, complex security controls, or breadth of administrative
tooling, although many NXDs now offer robust capabilities in these areas. 82
o SQL Integration: Support for standard SQL querying might be limited or non-
existent, requiring developers to learn XPath/XQuery. 82
o Ecosystem: Smaller market share compared to RDBMS, which might affect the
availability of third-party tools, experienced developers, and community support.
o Cost: Some high-performance commercial NXDs can have significant licensing
costs. 82
Data Model Fit Any XML; Poor Best for Hybrid; Good Best for semi-
fit for querying structured, data- with schema structured,
centric XML support document-
centric XML
65
Schema High (stores Low (tied to Medium (can High (often
Flexibility anything) relational store w/o schema-agnostic
schema) schema; changes or flexible)
may be hard)
Data Integrity None inherent High (via Medium (via Medium (via
to XML content RDBMS optional XML optional XML
constraints) Schema Schema
validation) validation)
XML Fidelity High (exact Low (structure Medium (logical High (logical
copy, esp. lost) structure structure
CLOB) preserved, preserved)
physical may
vary)
The dichotomy between storing XML in relational systems versus native XML databases
illustrates a classic technological dilemma: adapt the established, ubiquitous technology
(RDBMS) to handle a new data format, or develop a new technology (NXD) specifically
tailored to that format. RDBMS approaches, like shredding or CLOB storage,
72
fundamentally attempt to fit XML within the relational paradigm, often leading to
compromises in terms of performance, fidelity, or flexibility. Native XML databases,
72
conversely, build their architecture around the XML model itself, prioritizing efficient
66
handling of hierarchical structures and XML-specific querying, but potentially sacrificing
some of the maturity or broad ecosystem of RDBMS. 72
However, the landscape is not static. The development and enhancement of XMLType
data types and associated features (like XML indexing and integrated XPath/XQuery
support) within major relational databases represent a significant evolution. This trend
85
Task: Divide students into groups and present them with the following scenarios. Each
group should discuss the pros and cons of storing the described XML data using (a)
CLOB/BLOB in RDBMS, (b) Shredding to RDBMS, (c) XMLType in RDBMS, and (d) a
Native XML Database. They should recommend an approach for each scenario and
justify their choice.
67
queries across the content of many records are rare, but preserving the exact
original document structure is important for compliance.
• Scenario 3: Configuration Files: A software application uses XML files to store its
configuration settings, including nested sections for database connections, UI
preferences, and plugin settings. The application reads the entire configuration on
startup and occasionally updates specific values. The structure might evolve slightly
between application versions.
• Scenario 4: Digital Library: A university library digitizes historical manuscripts,
encoding them in TEI (Text Encoding Initiative) XML. These documents contain rich
markup for text structure, annotations, and metadata. Researchers need to perform
complex structural queries (e.g., find all annotations within chapter headings) and
full-text searches across the entire collection. The XML structure is complex and
document-centric.
XML's structure, being hierarchical rather than tabular, necessitates query languages
different from SQL used for relational databases. These languages need to navigate the
tree structure and select nodes (elements, attributes, text) based on their path, names,
values, and relationships to other nodes. XPath provides the foundation for path
52
navigation, while XQuery builds upon it to offer a more complete, functional query
language. 55
XPath is a language for addressing and selecting parts of an XML document. It uses a
46
path-based syntax, similar to file system paths, to navigate the XML tree. XPath is not
51
68
typically used standalone but is a crucial component within other technologies like
XSLT, XQuery, XML Schema (for key constraints), DOM libraries, and XML databases. 4
• Syntax Components:
o Location Path: An expression that selects nodes. It consists of one or more
location steps, separated by /.
o Location Step: Has three parts: an axis, a node test, and zero or more
predicates.
▪ Axis: Specifies the relationship between the selected nodes and the
context node (the node from which the step is evaluated). Key axes 51
include:
▪ child: Selects children (default axis if none specified). 91
▪ following: Selects all nodes after the context node in document order,
excluding descendants. 91
▪ preceding: Selects all nodes before the context node in document order,
excluding ancestors. 91
▪ Node Test: Specifies the type or name of the nodes to select along the
chosen axis. Examples:
52
69
▪ text(): Selects text nodes.
▪ node(): Selects any node of any type.
▪ comment(): Selects comment nodes.
▪ processing-instruction(): Selects processing instruction nodes.
▪ Predicate: Filters the node-set selected by the axis and node test.
Enclosed in square brackets [...]. Can contain:
52
based.
▪ Boolean expressions involving comparisons (=, !=, <, >, <=, >=),
functions, or other XPath expressions relative to the node being tested
(e.g., [@type='mobile'], [price > 50], [starts-with(name, 'A')],
[count(phone) > 1]). 52
▪ Existence tests (e.g., [email] selects nodes that have at least one email
child). 52
• Absolute vs. Relative Paths: Paths starting with / begin at the document's root
node. Paths starting with // begin searching from the root but match anywhere.
Paths not starting with / or // are evaluated relative to the current context node.
• Functions: XPath includes a core library of functions for various operations. 50
Works cited
70
5. XML Guides - Extensible Markup Language - MDN Web Docs, accessed April 24,
2025, [Link]
6. Semi-structured data - Wikipedia, accessed April 24, 2025,
[Link]
7. Basic HTML syntax - Learn web development | MDN, accessed April 24, 2025,
[Link]
US/docs/Learn_web_development/Core/Structuring_content/Basic_HTML_syntax
8. Python XML Tutorial: Element Tree Parse & Read - DataCamp, accessed April
24, 2025, [Link]
9. XML DTD - W3Schools, accessed April 24, 2025,
[Link]
10. What is semi-structured data? - CrowdStrike, accessed April 24, 2025,
[Link]
structured-data/
11. Structured Data Versus Semi-Structured Data | Snowflake, accessed April 24,
2025, [Link]
data/
12. What is Semi Structured Data? - Sotero, accessed April 24, 2025,
[Link]
13. Unstructured Data: Structured vs Semi-Structured | Starburst, accessed April 24,
2025, [Link]
14. Structured vs. Semi-Structured vs. Unstructured Data in PostgreSQL | Timescale,
accessed April 24, 2025, [Link]
structured-vs-unstructured-data-in-postgresql
15. What Is Structured, Semi-Structured and Unstructured Data? - SingleStore,
accessed April 24, 2025, [Link]
semi-structured-and-unstructured-data/
16. Difference between Structured, Semi-structured and Unstructured data |
GeeksforGeeks, accessed April 24, 2025,
[Link]
and-unstructured-data/
71
17. Is XML semi structured data? - Stack Overflow, accessed April 24, 2025,
[Link]
18. XSLT: Extensible Stylesheet Language Transformations - XML - MDN Web Docs,
accessed April 24, 2025, [Link]
US/docs/Web/XML/XSLT
19. Understanding HTML, XML and XHTML | WebKit, accessed April 24, 2025,
[Link]
20. W3C XML Schema (XSD) Validation online, accessed April 24, 2025,
[Link]
21. Validate an XML document by using DTD, XDR, or XSD - Visual Basic - Learn
Microsoft, accessed April 24, 2025, [Link]
us/troubleshoot/developer/visualstudio/visual-basic/language-compilers/validate-
xml-document-by-dtd-xdr-xsd
22. Difference between dtd and xsd | PDF - SlideShare, accessed April 24, 2025,
[Link]
23. Difference between Document Type Definition (DTD) and XML ..., accessed April
24, 2025, [Link]
definition-dtd-and-xml-schema-definition-xsd/
24. Understanding the Advantages & Disadvantages of DTD in XML - Hurix Digital,
accessed April 24, 2025, [Link]
advantages-and-disadvantages/
25. Describing your Data: DTDs and XML Schemas, accessed April 24, 2025,
[Link]
26. DTD vs XSD | Learn the Difference between DTD and XSD - EDUCBA, accessed
April 24, 2025, [Link]
27. xml - How to choose between DTD and XSD - Stack Overflow, accessed April 24,
2025, [Link]
and-xsd
28. DTD or XML Schema. Which one is better? [closed] - Stack Overflow, accessed
April 24, 2025, [Link]
which-one-is-better
72
29. What is DTD in XML - GeeksforGeeks, accessed April 24, 2025,
[Link]
30. W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures, accessed
April 24, 2025, [Link]
31. W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes, accessed
April 24, 2025, [Link]
32. XML Schema (XSD) Validation with XmlSchemaSet - .NET ..., accessed April 24,
2025, [Link]
validation-with-xmlschemaset
33. DTD versus XSD - Oracle Forums, accessed April 24, 2025,
[Link]
34. XML Validation with XSD in Visual Studio IDE - Stack Overflow, accessed April
24, 2025, [Link]
visual-studio-ide
35. How to Parse XML in Python | ScrapingAnt, accessed April 24, 2025,
[Link]
36. Java Architecture for XML Binding (JAXB) - Oracle, accessed April 24, 2025,
[Link]
37. How to generate xml files from xsd? (Java in General forum at Coderanch),
accessed April 24, 2025, [Link]
xsd
38. CSS: Cascading Style Sheets - MDN Web Docs, accessed April 24, 2025,
[Link]
39. Documentation of HTML and CSS - The freeCodeCamp Forum, accessed April
24, 2025, [Link]
css/551354
40. CSS - Wikipedia, accessed April 24, 2025, [Link]
41. XML in Mozilla - Archive of obsolete content | MDN - Cach3, accessed April 24,
2025, [Link]
US/docs/Archive/Mozilla/XML_in_Mozilla
73
42. Transforming with XSLT - Web APIs | MDN, accessed April 24, 2025,
[Link]
US/docs/Web/API/Document_Object_Model/Transforming_with_XSLT
43. How to style SVG with external CSS? - Stack Overflow, accessed April 24, 2025,
[Link]
44. An overview - XSLT: Extensible Stylesheet Language Transformations - MDN
Web Docs, accessed April 24, 2025, [Link]
US/docs/Web/XML/XSLT/Guides/Transforming_XML_with_XSLT/An_Overview
45. Selectors Level 4 - W3C, accessed April 24, 2025,
[Link]
46. XML: Extensible Markup Language - MDN Web Docs, accessed April 24, 2025,
[Link]
47. Transforming XML with XSLT - XSLT: Extensible Stylesheet ..., accessed April 24,
2025, [Link]
US/docs/Web/XML/XSLT/Guides/Transforming_XML_with_XSLT
48. XSLT - Wikipedia, accessed April 24, 2025, [Link]
49. XSL Transformations (XSLT) Version 2.0 (Second Edition) - W3C, accessed April
24, 2025, [Link]
50. XPath functions - MDN Web Docs, accessed April 24, 2025,
[Link]
51. XPath - XML: Extensible Markup Language - MDN Web Docs, accessed April 24,
2025, [Link]
52. XPath | Introduction to Path Description Language - IONOS, accessed April 24,
2025, [Link]
tutorial/
53. XPath reference - MDN Web Docs - Mozilla, accessed April 24, 2025,
[Link]
54. DOM scripting introduction - Learn web development | MDN, accessed April 24,
2025, [Link]
US/docs/Learn_web_development/Core/Scripting/DOM_scripting
74
55. Essential XQuery - The XML Query Language - UJI, accessed April 24, 2025,
[Link]
56. Reg: Difference between XQuery and XPath - Oracle Forums, accessed April 24,
2025, [Link]
and-xpath-6600
57. XHTML - MDN Web Docs Glossary: Definitions of Web-related terms, accessed
April 24, 2025, [Link]
58. Why did XML lose out to XHTML, then HTML 5, on the web?, accessed April 24,
2025, [Link]
lose-out-to-xhtml-then-html-5-on-the-web
59. HTML - MDN Web Docs Glossary: Definitions of Web-related terms, accessed
April 24, 2025, [Link]
60. HTML5 - Wikipedia, accessed April 24, 2025, [Link]
61. 14 The XML syntax - HTML Spec WHATWG, accessed April 24, 2025,
[Link]
62. : The HTML Document / Root element - HTML: HyperText Markup Language -
MDN Web Docs, accessed April 24, 2025, [Link]
US/docs/Web/HTML/Element/html
63. Introduction to the DOM - Web APIs | MDN, accessed April 24, 2025,
[Link]
US/docs/Web/API/Document_Object_Model/Introduction
64. JavaScript - W3C DOM - Introduction - QuirksMode, accessed April 24, 2025,
[Link]
65. Using the Document Object Model - Web APIs - MDN Web Docs, accessed April
24, 2025, [Link]
US/docs/Web/API/Document_Object_Model/Using_the_Document_Object_Model
66. Document Object Model (DOM) - Web APIs - MDN Web Docs, accessed April 24,
2025, [Link]
US/docs/Web/API/Document_Object_Model
75
67. Using the W3C DOM Level 1 Core - Web APIs, accessed April 24, 2025,
[Link]
W3C_DOM_Level_1_Core
68. Introduction to the DOM - Web APIs, accessed April 24, 2025,
[Link]
69. Document Object Model - Devopedia, accessed April 24, 2025,
[Link]
70. XML Parsing for Java, accessed April 24, 2025, [Link]
documents/oracle/E11882_01/appdev.112/e10708/adx_j_parser.htm
71. python - XML parsing - ElementTree vs SAX and DOM - Stack Overflow,
accessed April 24, 2025, [Link]
elementtree-vs-sax-and-dom
72. [Link], accessed April 24, 2025,
[Link]
73. Parsing an XML File Using SAX (The Java™ Tutorials > Java API for ..., accessed
April 24, 2025, [Link]
74. How do I parse my simple XML file with Java and SAX? - Stack Overflow,
accessed April 24, 2025, [Link]
parse-my-simple-xml-file-with-java-and-sax
75. Trail: Java API for XML Processing (JAXP) (The Java™ Tutorials), accessed April
24, 2025, [Link]
76. JAXP vs JAXB: XML Processing APIs Compared - Baeldung, accessed April 24,
2025, [Link]
77. [Link] — The ElementTree XML API — Python 3.13 ..., accessed
April 24, 2025, [Link]
78. How to Parse XML in Python? Multiple Methods Covered - Bright Data, accessed
April 24, 2025, [Link]
79. Python lxml tutorial: XML processing and web scraping - Apify Blog, accessed
April 24, 2025, [Link]
80. python - How to write XML declaration using [Link] - Stack
Overflow, accessed April 24, 2025,
76
[Link]
xml-etree-elementtree
81. JAXB Release Documentation - Java EE, accessed April 24, 2025,
[Link]
82. The Advantages/Disadvantages of XML compared to RDMS - Stack Overflow,
accessed April 24, 2025, [Link]
advantages-disadvantages-of-xml-compared-to-rdms
83. Modeling: Xml vs. Relational Database - Stack Overflow, accessed April 24, 2025,
[Link]
84. NATIVE XML DATABASES vs. RELATIONAL DATABASES IN DEALING WITH
XML DOCUMENTS Gordana Pavlovic-Lazetic, accessed April 24, 2025,
[Link]
85. CLOB Vs XMLTYPE - Oracle Forums, accessed April 24, 2025,
[Link]
86. XML Data – To be stored or not to be stored, and beyond… - http, accessed April
24, 2025, [Link]
to-be-stored-and-beyond%E2%80%A6/
87. XML usage in relational databases | Open Textbooks for Hong Kong, accessed
April 24, 2025, [Link]
88. 9 Critical Types of XML Tools for Developers - Sonra, accessed April 24, 2025,
[Link]
89. XPath Quick Reference (XQuery and XSLT Reference Guide) — MarkLogic 9
Product Documentation, accessed April 24, 2025,
[Link]
90. Difference Between XQuery and XPath | GeeksforGeeks, accessed April 24,
2025, [Link]
91. Axes - XPath - MDN Web Docs - Mozilla, accessed April 24, 2025,
[Link]
92. XQuery vs XPath | Learn Top 14 Comparisons with Infographics - EDUCBA,
accessed April 24, 2025, [Link]
77