XML - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

XML Tags

XML Tags

shape Description

A tag is a non-various leveled watchword or term doled out to a bit of data. This sort of metadata depicts a thing and permits it to be discovered again by perusing or looking. Labels are by and large picked casually and by and by the thing's maker or by its viewer, contingent upon the framework. Tagging was advanced by sites connected with Web 2.0 and is an essential element of many Web 2.0 administrations. It is currently a likewise piece of some desktop programming.

List Of XML Tags

shape Description

The following are the list of tags.

Start Tag

The start of each non-purge XML component is set apart by a begin tag. A case of begin tag is as follows. [xml]<splessons>[/xml]

End Tag

Each component that has a begin tag ought to end with an end-tag. A case of end-tag is as follows. [xml]</splessons>[/xml]

Empty Tag

The content that shows up between begin tag and end tag is called content. A component which has no substance is named as void. A vacant component can be spoken to in two courses as follows. [xml]<hr></hr>[/xml]

Rules Of XML Tags

shape Description

Following is the rule one. The XML tags are case-delicate. Taking after line of code is a case of wrong language structure , as a result of the case contrast in two labels, which is dealt with as incorrect sentence structure in XML. [xml]<splesson>This is wrong syntax</Splesson>[/xml] Taking after code demonstrates a right way, where the developer utilizes a similar case to name the begin and the end tag. [xml]<splesson>This is right syntax</splesson>[/xml] Following is the rule two. XML labels must be shut in a suitable request, i.e., an XML tag opened inside another component must be shut before the external component is shut. For instance, as follows. [xml] <outer_element> <internal_element> This tag is closed before the outer_element </internal_element> </outer_element> [/xml] Following is an example. [xml]<?xml version="1.0" encoding="UTF-8"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>[/xml]

XML Elements

shape Description

Elements is the most important part of the XML Document. XML Elements are logical units of information in an XML document and the information is enclosed in angular brackets < >. Syntax: [xml] <element-name attribute1 attribute2> ....content </element-name> [/xml] where, element-name is the name of the XML element. XML Elements names are case-sensitive i.e. when element starts with upper case letter, it should end with upper-case only. Likewise for lower case also. attribute1 and attribute2 are element attributes which are partitioned by white spaces. An attribute provides single property of an element. It uses a name and value combination that are separated by equal "=" sign. [xml]<a href="http://www.splessons.com/">SPLessons</a>[/xml] In the above example, href is the name of attribute and http://www.splessons.com/ is the value of attribute. Example - 1: [xml] <category>Programming</category> [/xml] Example - 2: [xml] <?xml version="1.0"?> <contact-info> <name>Mike</name> <company>SPLessons</company> <phone>+(011) 011223366</phone> </contact-info> [/xml] Elements can contain text, sub-elements, media objects and attributes. Every XML document can have multiple elements inside it and the scope of them will be decided by the begin and end tags or by empty element.

Root Element

shape Description

XML documents must have a root element inside which all the sub-elements are defined. [xml] <root> <child> <subchild>.....</subchild> </child> </root> [/xml] In the below example, the root element is <note> [xml] <?xml version="1.0" encoding="UTF-8"?> <note> <to>Michael</to> <from>Randy</from> <heading>Invitation</heading> <body>Party Tonight!!</body> </note> [/xml]

Close element

shape Description

All XML elements should have a closing tag( /> ) otherwise, the error is shown. [xml] <!------illegal declaration and not considered-----> <p>This is a paragraph <!-------Legal declaration and considered-----> <p>This is a paragraph</p> [/xml]

Empty element

shape Description

Elements with no content can be expressed like below: [xml]<category></category>[/xml] In shorthand, elements with no content can be defined as below. [xml]</category>[/xml]

XML Elements Naming Rules

shape Description

  • XML Element names must start with a letter either upper or lowercase, A-Z or an underscore(_).
  • It may contain any combination of letters, numbers, dashes(-) or underscores after the first character.
  • It can be of any length.
  • XML element names are case-sensitive.
  • The elements cannot have spaces.

Extensible XML Elements

shape Description

Elements in XML are extensible and can take in more data if required. Suppose, consider the below example which has three elements containing student information. [xml] <student> <id>1</id> <name>John</name> <class>10th standard</class> </student> [/xml] If the school management wants to add some more data to the existing one after few days, that can be done as XML elements are extensible. Additionally for the above details, father-name and mother-name are added. [xml] <student> <id>1</id> <name>John</name> <class>10th standard</class> <father-name>Mike</father-name> <mother-name>Rita</mother-name> </student> [/xml]

Summary

shape Key Points

  • Elements in XML are extensible and can take in more data if required.
  • A Namespace is a set of diversified names through which element and attribute names can be assigned to group.
  • Attribute values should be within single or double quotation marks.
  • XML Elements are logical units of information in an XML document.
  • XML element names are case-sensitive.
  • Elements in XML are extensible and can take in more data if required.