XML
What does XmlValidatingReader class do?
Dec 7th
XmlTextReader class does not validate the contents of an XML source against a schema. The correctness of XML documents can be measured by two things is the document well formed and is it valid. Well-formed means that the overall syntax is correct. Validation is much deeper which means is the XML document is proper w.r.t schema defined.
So the XmlTextReader only checks if the syntax is correct but does not do validation. There’s where XmlValidatingReader class comes in to picture. So this again comes at a price as XmlValidatingReader have to check for DTD and Schema’s there are slower compared to More >
Explain simple Walk through of XmlReader ?
Dec 7th
In this section we will do a simple walkthrough of how to use the “XmlReader” class. Sample for the same is available in both languages (C# and VB.NET) which you can find in “WindowsApplicationXMLVBNET” and “WindowsApplicationCSharp” folders. Task is to load “TestingXML.XML” file and display its data in a message box. You can find “TestingXML.XML” file in “BIN” directory of both the folders. Below is the display of “TestingXML.XML” file and its content.
How do we access attributes using “XmlReader”?
Dec 7th
Below snippets shows the way to access attributes. First in order to check whether there any attributes present in the current node you can use “HasAttributes” function and use the “MoveToNextAttribute” method to move forward in attribute. In case you want to move to the next element use “MoveToElement()”.
if (reader.HasAttributes)
{
while(reader.MoveToNextAttribute())
{
// your logic goes here
string pdata = reader.Value
}
}
reader.MoveToElement();
What is XMLTextReader?
Dec 7th
The “XmlTextReader” class helps to provide fast access to streams of XML data in a forward-only and read-only manner. It also checks if the XML is well-formed. But XMLTextReader does not validate against a schema or DTD for that you will need “XmlNodeReader” or “XmlValidatingReader” class.
Instance of “XmlTextReader” can be created in number of ways. For example if you want to load file from a disk you can use the below snippets.
XmlTextReader reader = new XmlTextReader(fileName);
To loop through all the nodes you need to call the “read()” method of the “XmlTextreader” object. “read()” method returns “true” if there are More >
What is an XMLReader Class?
Dec 7th
It is an abstract class available from System.XML namespace. XML reader works on a read-only stream browsing from one node to other in a forward direction. It maintains only a pointer to the current node but has no idea of the previous and the next node. You can not modify the XML document, you can only move forward.
What is the concept of XPOINTER?
Dec 7th
XPOINTER is used to locate data within XML document. XPOINTER can point to a particular portion of a XML document, for instance
address.xml#xpointer(/descendant::streetnumber[@id=9])
So the above XPOINTER points streetnumber=9 in “address.xml”.
Define XPATH?
Dec 7th
It is an XML query language to select specific parts of an XML document. Using XPATH you can address or filter elements and text in a XML document. For instance a simple XPATH expression like “Invoice/Amount” states find “Amount” node which are children of “Invoice” node.
What is XSLT?
Dec 7th
XSLT is a rule based language used to transform XML documents in to other file formats. XSLT are nothing but generic transformation rules which can be applied to transform XML document to HTML, CS, Rich text etc.
What are the core functionalities in XML .NET framework? Can you explain in detail those functionalities?
Dec 7th
The XML API for the .NET Framework comprises the following set of functionalities:
XML readers
With XML readers the client application get reference to instance of reader class. Reader class allows you to scroll forward through the contents like moving from node to node or element to element. You can compare it with the “SqlDataReader” object in ADO.NET which is forward only. In short XML reader allows you to browse through the XML document.
XML writers
Using XML writers you can store the XML contents to any other storage media. For instance you want to store the whole in memory XML to a physical file More >
