XML (Extensible Markup Language) is a simple text-based format for representing structured information: documents, data, configuration, books, transactions, invoices, and much more. It was derived from an older standard format called SGML.
XML Used For
XML is one of the most widely-used formats for sharing structured information today: between programs, between people, between computers and people, both locally and across networks
Example of XML
<Product ID="1976"> <name>Intel Processor I5</name> <description>Intel processors are the best processor available in market.</description> <price>$200</price> </Product>
If you are already familiar with HTML, you can see that XML is very similar. However, the syntax rules of XML are strict: XML tools will not process files that contain errors, but instead will give you error messages so that you fix them. This means that almost all XML documents can be processed reliably by computer software.
The main differences from HTML:
All elements must be closed or marked as empty.
Empty elements can be closed,
<price></price> or you can use
<price /> in short.
In HTML, you only need to quote an attribute value under certain circumstances (it contains a space, or a character not allowed in a name), but the rules are hard to remember. In XML, attribute values must always be quoted:
<Product ID="1976" />
In HTML there is a built-in set of element names (along with their attributes). In XML, there are no built-in names (although names starting with xml have special meanings).
In HTML, there is a list of some built-in character names like é for é but XML does not have this. In XML, there are only five built-in character entities: <, >, &, " and ' for <, >, &, " and ' respectively. You can define your own entities in a Document Type Definition, or you can use any Unicode character.
In HTML, there are also numeric character references, such as & for &. You can refer to any Unicode character, but the number is decimal, whereas in the Unicode tables the number is usually in hexadecimal. XML also allows hexadecimal references: & for example.
XML has a number of advantages over many other formats. For any particular scenario, you might be able to come up with a better format, but then you would have to include costs of converting and processing your format, and of training, and of the XML-specific editing and searching tool that are now very widely available. Some of the advantages of XML include:
Redundancy: XML markup is very verbose. For example, every end tag must be supplied, such as in the example. This lets the computer catch common errors such as incorrect nesting.
Self-describing: The readability of XML (it is a text-based format) and the presence of element and attribute names in XML means that people looking at an XML document can often get a head start on understanding the format (and it also helps people to find mistakes!)
Network effect and the XML Promise: Any XML document can be read and processed by any XML tool whatsoever. Of course, some XML tools might want specific XML markup, but the XML format itself can be read by any XML parser: you can't say, this XML document is only to be processed by such-and-such a tool.
This means that every new XML document increases the value of every other XML document, and of every XML tool, and every new XML tool increases the value of every XML document and hence of every other tool. Today, XML is the most widely-used format of its kind anywhere in the world.
Started career with .Net, and not working on client side technologies like angular, React etc. since last 12 years. But C# is really amazing language and I like to learn everything about C# and want to share whatever I know.
|By Alicia Gonzalez On 25 Dec, 12 Viewed: 419|
Reading and writing in xml can be done in different ways, some common classes people use are XmlTextReader, XmlTextWriter , XmlDocument but we will use XDocument. By using the other classes say XmlTextReader we need to use the while loop to read and check every node by using XmlNodeType, for a long... By Ali Adravi On 20 Dec 2014 Viewed: 3,469
Convert XML or JSON into a class by using visual studio is as easy as just copy and two clicks, never matter how big or how complicated is our XML or JSON. In this article we will create some dummy XML and json and will try to convert them into class without writing a single property manually. It... By Ali Adravi On 20 Dec 2014 Viewed: 1,346
When there was XmlDocument why we need XDocument, is there any better feature available with XDocument, answer is yes, XDocument has a number of benefits, easy to create, easy to update, easy to search, ability to use LINQ to XML, cleaner object model etc. In this post we will see some examples... By Ali Adravi On 16 Mar 2013 Viewed: 2,446
HTML syntax, this is the format suggested for most authors. It is compatible with most legacy Web browsers. If a document is transmitted with the `text/html MIME` type, then it will be processed as an HTML document by Web browsers. This specification defines version 5 of the HTML syntax, known as... By Alicia Gonzalez On 25 Dec 2012 Viewed: 549
In some situations we need to create website menu from database, say our application have ability to create pages so that must also need to have a menu item to go to that page. So how to create menu with all those nice CSS and other settings, I think XSLT is best to use in these... By Hamden On 16 Mar 2013 Viewed: 1,185