What is XML ? Use of XML in ASP.Net.


Use of xml in asp.net. Structure of XML file. XML stands for Extensible Markup Language. The extension of xml file is .xml. It is a textual data format with strong support via Unicode for the languages of the world.

XML stands for Extensible Markup Language. The extension of xml file is .xml. It is a textual data format with strong support via Unicode for the languages of the world.
The structure of XML is like below:


<Root Element>
<Parent1>
<Child1>...</Child1>
<Child2>...</Child2>
</Parent1>

<Parent2>
<Child1>...</Child1>
<Child2>...</Child2>
</Parent2>

</Root Element>


It means in an XML file only one root element can be possible.

While opening an XML file you will find below line on top of the page:

<?xml version="1.0" encoding="UTF-8" ?>


The above line is called XML declaration.

XML is used to store the record in text format. User can store records in XML file in the form of node. As like SQL tables, XML file can be bind with Gridview, Datalist and other asp.net data control. The main benefit of XML is that you can define your own tag, with your own comfort.

see the below example:

<Post>
<Head>
<username>dotnetspider</username>
<id>001</id>
</Head>
</Post>


To the beginners: If you want to learn XML then you must be aware about HTML.


Comments

Author: DotNetLearner02 Feb 2012 Member Level: Silver   Points : 0

Hello Mr. Srivastava,

Your post is very useful for me.
Actually I was searching for that only.
It helps me.
Thanks for your post.

Author: ketan Italiya24 Sep 2013 Member Level: Gold   Points : 2

XML is designed to transport and store data.Data can stored separate xml files.
Exapmle:
suppose you developing a mail send application that time you can store the your (UserId,Password, portno, and domain etc)... in xml file.
and read these entity to xml files because these entities are fixed your application.

Author: ketan Italiya24 Sep 2013 Member Level: Gold   Points : 6

XML Namespace

The System.Xml namespace provides a rich set of classes for processing XML data. The commonly used classes for working with XML data are:

XmlTextReader: Provides forward only access to a stream of XML data and checks whether or not an XML document is well formed. This class neither creates as in-memory structure nor validates the XML document against the DTD. You can declare an object of the XmlTextReader class by including the System.Xml namespace in the application. The syntax to declare an object of this class is as follows:

XmlTextReader reader = new XmlTextReader("XML1.xml");

It is important to note that the .xml file you pass as an argument to the constructor of the XmlTextReader class exists in the \WINNT\System32 folder.

XmlTextWriter: Provides forward only way of generating streams or files containing XML data that conforms to W3C XML 1.0. If you want to declare an object of the XmlTextWriter class, you must include the System.Xml. The syntax to decare an object of this class is as follows:

XmlTextWriter writer = new XmlTextWriter(Response.Output);

Here Response.Output represents an outgoing HTTP response stream to which you want to send the XML data.

XmlDocument: Provides navigating and edinting features of the nodes in an XML document tree. XmlDocument is the most frequently used class in ASP.NET applications that use XML documents. It also supports W3C XML DOM. XML DOM is an in-memory representation of an XML document. It represents data in the form of hierarchically organized object nodes and allows you to programmatically access and manipulate the elements and attributes present in an XML document.

XmlDocument doc = new XmlDocument();

XmlDataDocument: Provides support for XML and relational data in W3C XML DOM. You can use this class with a dataset to provide relational and non-relational views of the same set of data. This class is primarily used when you want to access the functions of ADO.NET.

Author: Phagu Mahato13 Dec 2013 Member Level: Gold   Points : 8

XML stands for extensible Markup Language.XML is designed to transport and store data .XML (Extensible Markup Language) is a flexible way to create common information formats and share both the format and the data on the World Wide Web, intranets, and elsewhere. For example, computer makers might agree on a standard or common way to describe the information about a computer product (processor speed, memory size, and so forth) and then describe the product information format with XML. Such a standard way of describing data would enable a user to send an intelligent agent (a program) to each computer maker's Web site, gather data, and then make a valid comparison. XML can be used by any individual or group of individuals or companies that wants to share information in a consistent way.

With XML, data can be stored in separate XML files. This way you can concentrate on using HTML/CSS for display and layout, and be sure that changes in the underlying data will not require any changes to the HTML.With a few lines of JavaScript code, you can read an external XML file and update the data content of your web page
WSDL for describing available web services.Features of XML.
WAP and WML as markup languages for handheld devices
RSS languages for news feeds
XML tags are not predefined. You must define your own tags
XML is designed to be self-descriptive
XML is a W3C Recommendation
RDF and OWL for describing resources and ontology
SMIL for describing multimedia for the web
XML is a markup language much like HTML
XML was designed to carry data, not to display data



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: