What Is XML?
XML
stand for Extensible Markup Language. The Extensible Markup Language (XML) is
the universal language for data on the web.
Extensible Markup Language (XML)
documents are universally accepted as a standard way of representing
information in platform and language independent manner.
Extensible Markup Language (XML) is
universal standard for information interchange.
Extensible Markup Language (XML)
documents can be created in any language and can be used in any language.
What Are the Benefits of XML?
The Benefits of using XML on the web -
1. Simplicity - It is very easy to read and understand.
2. Extensibility - There is no fixed set of tags and the tags
can be created as per your needed.
3. Openness - It is a W3C standard, endorsed by software
industry market leaders.
4. Self-description - XML documents can be stored without such
definitions, because they contain Meta data in the form of tags and attributes.
5. Contains machine-readable context information
6. Separates content from presentation
7. Supports multilingual documents and Unicode
8. Facilitates the comparison and aggregation of
data
9. Can embed multiple data types
10. Can embed existing data
Is XML case sensitive?
Yes, XML is a case sensitive language.
What Is XML Schema?
XML Schema describes the structure of
an XML instance document by defining what each element must or may contain.XML
Schema is expressed in the form of a separate XML file.
Note –some XML data types are
predefined and new ones can be created.
As an Example,
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element
name="eleName">
<xsd:complexType>
What Is a well-formed XML
document?
If a document is syntactically correct
it can be called as well-formed XML document.
The basic rules of well-formed XML
document:
1. Each and every open tag must be closed.
2. XML is case-sensitive so that every open tag
must exactly match the closing tags.
3. Each and every element must be embedded within
a single root element.
4. All child tags must be closed before parent
tags.
What Are the difference between
XML and HTML?
The HTML is used to mark up text
whereas XML is used to mark up data.
The HTML is used for UI displaying
purpose but the XML is used for data representation.
The HTML uses a fixed, unchangeable
set of tags but in XML, you make up your own tags.
What Is a valid XML document?
If a document is structurally correct
(with the above well-formed XML rules) then it can called as valid XML
documents.
How does the XML structure is
defined?
The Extensible Markup Language (XML)
document will have a structure which has to be defined before we can create the
documents and work with them. The structural rules can be defined using
many
available technologies, but the following are popular way of doing so,
1) Document Type Definition (DTD)
2) Schema
What Is DTD?
The DTD stands for Document Type
Definition and used to define the legal building blocks of an XML document.
DTD defines rules for a specific type of
document i.e.
1. Names of elements
2. Order of elements
3. Proper nesting and containment of elements
4. Element attributes
What Is XML Schema Element?
The schema element defines the root
element of a schema.
As an Example,
<?xml version="1.0"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="values"
type="xs:string" />
</xs:schema>
How To apply a DTD to an XML
document?
Include the DTD's element definitions
within the XML document itself. Also provide the DTD as a separate file, whose
name you reference in the XML document.
What Are differences between DTD
and Schema?
The DTD follow SGML syntax but the
Schema document is an XML document.
In DTD everything is treated as text
where as the Schema supports variety of dataTypes similar to programming
language.
In Schema, we can inherit, create
relationship among elements but not possible in DTD.
What Is a Complex Element?
A complex element is an XML element
that contains other elements & attributes as well.
The Types of complex elements:
1. An empty element
2. A complex element that contain only text
3. A complex element that contain only other
elements
4. A complex element that contain both text and
other elements
What Is a Simple Element?
A simple element is an XML element
that can contain only text.
Types of simple elements,
1. A simple element can't be empty
2. A simple element can't have attributes
3. A simple element contains text - it can be of
many different types.
What Are namespaces in XML? Why
are important?
XML namespaces are used for providing
uniquely named elements and attributes in an XML instance and the uniquely
named elements avoid name collisions on elements.
What Are the ways to use XML
namespaces?
There are two ways,
1. Fist one, declare a default namespace
2. Second one, associate a prefix with a
namespace, then use the prefix in the XML to refer to the namespace.
What Is the Global and Local
Elements in XML?
An element is global or local
depending on how it is defined in a schema.
Any element that is an immediate child of Schema, or is a ref to an
immediate child of Schema, is a global element.
All other elements are local elements.
What Is ElementFormDefault
attribute?
An XML Schema can define whether its
local elements must be qualified or unqualified in an XML document. This is declared with the
“elementFormDefault” attribute in the <schema> element. The two possible values are appropriately
named: qualified and unqualified.
What Is XmlReader class?
The XmlrReader class represents a
reader that provides fast, noncached, forward-only access from XML data. We
must need to import the Xml namespaces before using the XmlReader class in
C#.NET - using System.Xml;
What Is an XML parser?
A XML parser is a program that
"parses" XML and evaluates the XML code. Its use of XML parser is to
read XML document by using library.
The XML parsers basically convert code
into something that the hardware will recognize. The main objective of the
parsers is to transform XML into a readable code.
The Features of XML parser are,
1. Analyze the XML schema (XSD) or a significant
XML sample
2. Create an optimized relational target schema
3. Automatically processes the XML files
4. Can handle arbitrarily complex XML files and
supports the whole XSD spec
5. Provides data lineage in the form of a source
to target map
6. Scales for very large volumes
The Available Tools that use as parser,
1. XMLHttpRequest: XMLHttpRequest object has inbuilt parser.
2. Expat XML
Parser: Specially written in C language.
3. CodeBeauty
Parser: Free XML Viewer, XML Formatter and
convert XML document/string into readable format.
4. Alteryx
Parser Tool: The XML parse
tool reads in a chunk of Extensible Markup Language (XML) and parse it into
individual fields
What Is DOM?
The DOM stands for Document Object
Model.
DOM is a cross-platform and
language-independent standard object model for representing XML and related
formats.
DOM represents an XML document as a
tree model and the tree model makes the XML document hierarchal by nature. Each
and every construct of the XML document is represented as a node in the tree.
DOM is a programming interface for
HTML and XML documents.
What Is the difference between
DOM and HTML?
DOM is an abstraction of a structured
text. For web developers, this text is an HTML code, and the DOM is simply
called HTML DOM. Elements of HTML become nodes in the DOM. So, while HTML is a
text, the DOM is an in-memory representation of this text.
What Is SAX?
The SAX stands for Simple API for XML
processing and the SAX provides a mechanism for reading data from an XML
document.
SAX provides an event based processing
approach unlike DOM which is tree based.
What Are the differences between
DOM, SAX and StAX XML parsers?
DOM stands for Document Object Model
while SAX stands for Simple API for XML parsing.
SAX provides an event based processing
approach unlike DOM which is tree based.
DOM parser load full XML file in
memory and creates a tree representation of XML document, while SAX is an event
based XML parser and doesn't load whole XML document into memory.
StAX Much like SAX but instead of
responding to events found in the stream you iterate through the xml.
The difference between SAX and StAX is
that of push and pull. SAX Push Model and the StAX Pull Model.
StAX enables you to create
bidirectional XML parsers that are fast. It proves a better alternative to
other methods, such as DOM and SAX, both in terms of performance and usability.
What Are the interfaces of SAX
in XML?
The interfaces of SAX are,
DocumentHandler- It is used for getting event notification
relating to a document.
ErrorHandler-
It is used for handling error related notifications.
EntityResolver- It is used for reading external entities.
DTDHandler-
It is implemented to get the notifications related to declarations in DTD like
entities and notations
What Is XSL in XML?
XSL stands for eXtensible Stylesheet
Language.
XSL is used for displaying the
contents of XML documents.
XSL consists of three parts,
1. XSLT
2. XPath
3. XSL-FO
What Is XSLT in XML?
XSLT stands for eXtensible Stylesheet
Language Transformation.
XSLT is used for transformation of one
XML document into XHTML documents or to other XML documents.
XSLT uses XPath only.
What Is XPath in XML?
XPath is used to retrieve elements
from XML documents.
XPath expressions also can be use to
retrieve elements, attributes and values from XML files.
What Is XSL-FO?
XSL-FO is a markup language and used
to generate PDF, DOC files.
XSL-FO is part of XSL.
What Is CDATA in XML?
What does <![CDATA[]]>
node in a XML document?
CDATA stands for Character Data.
A CDATA section starts with
"<![CDATA[" and ends with "]]>": CDATA sections
cannot be nested.
A CDATA section contains text that
will NOT be parsed by a parser. Tags inside a CDATA section will NOT be treated
as markup and entities will not be expanded. The primary purpose is for
including material such as XML fragments, without needing to escape all the
delimiters.
From Wikipedia:
[In] an XML document or external
parsed entity, a CDATA section is a section of element content that is marked
for the parser to interpret as only character data, not markup.
As an Example,
<script>
<![CDATA[
function checkNumber(a,b)
{
if (a > b) then
{
return 1;
}
else
{
return 0;
}
}
]]>
</script>
In the example above, everything
inside the CDATA section is ignored by the parser.
Notes
- The "]]>" that marks the end of the CDATA section cannot contain
spaces or line breaks. Nested CDATA sections are not allowed.
What Is the difference between
CDATA and PCDATA?
CDATA means un-parsed character data
whereas PCDATA means parsed character data.
Is it possible to use graphics
in XML?
Yes, you can do using XLink and
XPointer.
The multiples graphics formats
supports,
GIF,JPG, PNG, CGM, EPS, TIFF, and SVG
Which are the types of parser in
XML?
List of XML parser are,
1. DOM Parser
2. SAX Parser
3. StAX Parser
4. JAXB
What Is XPOINTER in XML?
XPOINTER is a W3C recommendation.
XPOINTER is used to point data within
XML document and also used to locate the particular part of the XML document.