Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
XML declaration example
<?xml version = "1.0" encoding = "UTF-8" standalone = "yes"?>
XML document can optionally have an XML declaration. XML document without declaration is also valid
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
</student>
If the XML declaration is included, it must contain version number attribute
<?xml encoding="UTF-8" standalone="no"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
</student>
It will generate the following error:
error on line 1 at column 7: Malformed declaration expecting version
The names are always in lower case
<?xml Version="1.0" encoding="UTF-8" standalone="no"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
</student>
It will generate the following error:
error on line 1 at column 7: Malformed declaration expecting version
The XML declaration must begin with
<?xml
<? version="1.0" encoding="UTF-8" standalone="no"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
</student>
The following error will be generated:
error on line 1 at column 3: xmlParsePI : no target name
If document contains XML declaration, it must be the
first statement
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
</student>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
The error will be the following:
error on line 6 at column 6: XML declaration allowed only at the start of the document
The order of placing the parameters is important. The correct order is:
version
,
encoding
and
standalone
<?xml encoding="UTF-8" standalone="no" version="1.0"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
</student>
This will generate the following error:
error on line 1 at column 7: Malformed declaration expecting version
Either single or double quotes may be used. Here is valid XML document
<?xml version='1.0' encoding='UTF-8' standalone="no"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
</student>
An HTTP protocol can override the value of encoding that we put in the declaration.
by Valeri Tandilashvili
4 years ago
0
XML
XML Tutorial
0
XML Attribute
specifies a single property for the element, using a
name/value
pair. An XML-element can have
one or more
attributes
<a href = "http://www.applications.ge/">Applications.ge</a>
In the example
href
is the
attribute name
and
http://www.applications.ge
is the
attribute value
... XML attribute names (unlike HTML) are case sensitive. Which means that
HREF
and
href
are considered two different XML attributes
<?xml version="1.0"?>
<student>
    <a href="http://www.applications.ge/" hreF="HTTP://applications.ge/">Applications.ge</a>
</student>
Several different values for the same attribute is not allowed. An attribute name must not appear more than once in the same tags:
<?xml version="1.0"?>
<student>
    <a href="http://www.applications.ge/" href="HTTP://applications.ge/">Applications.ge</a>
</student>
The following error will appear on the browser
error on line 3 at column 73: Attribute 
href
redefined
Attribute names must always be defined without quotation marks, whereas attribute values must always appear in single or double quotation marks
<?xml version="1.0"?>
<student>
    <a "href"="http://www.applications.ge/">Applications.ge</a>
</student>
The following error will appear:
error on line 3 at column 8: error parsing 
attribute name
Attribute values must always be in quotation marks (single
'
or double
"
quotes)
<?xml version="1.0"?>
<student>
    <a href=http://www.applications.ge/>Applications.ge</a>
</student>
This incorrect syntax will generate the following error:
error on line 3 at column 13: AttValue: " or ' expected
by Valeri Tandilashvili
4 years ago
0
XML
XML attributes
XML Tutorial
0
Some characters are are not allowed in XML text because they are reserved by the XML itself. Hence, they cannot be used directly. If we need to include them in text, some replacement-entities are used. These symbols are:
<
- less than -
&lt;
>
- greater than -
&gt;
'
- ampersand -
&amp;
"
- apostrophe -
&apos;
&
- quotation mark -
&quot;
by Valeri Tandilashvili
4 years ago
0
XML
XML Tutorial
0
XML references allow us to have symbols in XML text, that are not allowed to be included directly. References begin with the symbol
&
which is a reserved character and end with the symbol
;
XML has two types of references: ... 1.
Entity Reference
− which contains a name between the start and the end delimiters. For example
&amp;
where amp is name. The name refers to
&
symbol. ... 2.
Character Reference
− contains reference, such as
&#65;
contains a hash mark
#
followed by a number. The number refers to the Unicode code of a character. In this case, 65 refers to alphabet
A
by Valeri Tandilashvili
4 years ago
0
XML
XML Tutorial
0
version 
- specifies the version used in the XML document (1.0)
encoding
- defines the character encoding used in the XML document (UTF-8)
standalone
- if the value is
yes
it means there is no external declaration required to parse the document (yes)
by Valeri Tandilashvili
4 years ago
0
XML
XML declaration
XML Tutorial
0
XML tags are
case-sensitive
- because of the case difference in two tags, which is treated as incorrect syntax in XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
   <address>Wrong syntax</ADdress>
   <hr />
</student>
This will generate the error:
error on line 6 at column 23: Opening and ending tag mismatch: address line 0 and ADdress
XML tags must be closed
in an appropriate order
, which means an XML element opened inside another element must be closed before the outer element
<outer_element>
   <internal_element>
      Right, because the inner tag is closed before the outer
   </internal_element>
</outer_element>
by Valeri Tandilashvili
4 years ago
0
XML
XML tags
XML Tutorial
0
XML empty tags
An empty element in XML document can be represented in two ways:
<?xml version="1.0" encoding="UTF-8"?>
<student>
   <name>George</name>
   <phone>(011) 123-4567</phone>
   <address></address>
   <city />
</student>
One way is
<address></address>
element and another is
<city />
. In other words, one with closing tag and another is self-closing tag.
by Valeri Tandilashvili
4 years ago
0
XML
XML tags
0
The symbols: hyphen
-
, under-score
_
and period
.
are allowed in element name. The XML example is valid
<?xml version="1.0" encoding="UTF-8"?>
<student>
   <first-name>George</first-name>
   <phone.mobile>(011) 123-4567</phone.mobile>
   <native_language>English</native_language>
   <city />
</student>
by Valeri Tandilashvili
4 years ago
0
XML
XML elements
XML Tutorial
0
- An element name can contain any alphanumeric characters. Allowed
symbols
in names are the hyphen
-
, under-score
_
, period
.
and digits
0-9
- Names are
case sensitive
, Address, address, and ADDRESS are different names. - Start and end tags of an element must be
the same
. - An element, which is a container, can contain
text
or
elements
<?xml version="1.0" encoding="UTF-8"?>
<student>
   <first-name>George</first-name>
   <phone.mobile>(011) 123-4567</phone.mobile>
   <native_language>English</native_language>
   <city />
</student>
Note: XML element name must not start with
.
,
-
,
digit
by Valeri Tandilashvili
4 years ago
0
XML
XML elements
XML Tutorial
0
XML comments
Similar to HTML comments, XML comment has the following syntax:
<!-- Our comment -->
XML comment example in XML document:
<?xml version="1.0" encoding="UTF-8"?>
<student>
    <!-- Some comment about the student -->
    <first-name>George</first-name>
    <phone.mobile>(011) 123-4567</phone.mobile>
    <tive_language>English</tive_language>
    <another_tag>some text</another_tag>
    <city />
</student>
by Valeri Tandilashvili
4 years ago
0
XML
XML comments
0
Results: 1580