This process of checking the structure of the XML document is called validating.
The software performing the task of validating is called a validating parser. You can add an XML Web Server control to a Web form by dragging the control from the Web forms tab of the toolbox.
In an XML document, you specify the structure of the data by creating a DTD or an XML schema.
So I want to validate the XML file to check if it is in the format that I expect.
So I guess I would need something like a schema to check just that it has to be through code. Edit I decided to use XML serialization so I know it will through an exception if it is the wrong format and ignore stuff that does not work.
In addition to just viewing data in the Data view, you can also add data directly to an existing XML document. When you want to access and display XML data in Web Applications, you use the XML Web server control and set its properties at design time.
For this, just click on the new row below the existing data and enter your values, and shown in the figure: An XML Web Server control is used to display the contents of an XML document without formatting or using XSL Transformations. In certain situation, you may need to display the XML data based on specific conditions.
The Read Xml method can read XML documents from the Stream, File, Text Reader, and Xml Reader sources.
The synatx for the Read Xml method is as follows: Reads any inline schema and loads the data.
So if I expect I don't want some other format to be in the file other then the one I expect. Like say I require that there must be some text in between tags. However I am not sure should I just go through it and C# to validate each of the records or should I try to make an xml schema to do it.
If I would want to do it through an xml schema with xml serialization how would that work? Check out How To Validate an XML Document by Using DTD, XDR, or XSD in Visual C# .
You can optionally specify a XSLT style sheet that formats the XML document before it is displayed in an XML server control. In such cases, you will have to access the XML data programmatically.