Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Different syntax for XPath Query

Answer»

Below are some usefull and more useable syntax in xpath all of these syntax are usefull when we are doing in xml

/catalog SELECTS the root element
/catalog/cdselects all the cd elements of the catalog element
/catalog/cd/price selects all the price elements ofall the cd elements of the catalog element
/catalog/cd[price>10.0]selects all the cd elements with price greater than 10.0
startswith a slash(/)representsan absolute path to an element
startswith TWO SLASHES(//)selectsall elements that satisfy the criteria
//cdselects all cd elements in the document
/catalog/cd/title| /catalog/cd/artist selects all the title and artist elements of the cd elements of catalog
//title| //artistselects all the title and artist elements in the document
/catalog/cd/*selects all the CHILD elements of all cd elements of the catalog element
/catalog/*/priceselectsall the price elements that are grandchildren of catalog
/*/*/priceselects all price elements which have two ancestors
//* selectsall elements in the document
/catalog/cd[1]selectsthe first cd child of catalog
/catalog/cd[last()] selectsthe last cd child of catalog
/catalog/cd[price]selects all the cd elements that have price
/catalog/cd[price=10.90]selects cd elements with the price of 10.90
/catalog/cd[price=10.90]/priceselects all price elements with the price of 10.90
//country selects all countryattributes
//cd[country]selects cd elements which have a " country " ATTRIBUTE
//cd[*]selects cdelements which have any attribute
//cd[country='UK']selects cd elements with " country " attribute equal to 'UK'
2.

Select XML Nodes by Name in c# code

Answer»

Select XML Nodes by NAME in c# code
To FIND nodes in an XML file we will use XPath expressions. Now we use Method XmlNode.SelectNodes which will returns a LIST of nodes selected by the XPath string.
Below is syntax and using of XML by example



Xml Node Example


Now comes to reading part we will use below code to read above XML

XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(myXMLExampleString);
XmlNodeList xmlnList = xmldoc.SelectNodes("/Students/Student");
foreach (XmlNode xn in xmlnList)
{
string firstName = xn["FName"].InnerText;
string LASTNAME = xn["LName"].InnerText;
Console.WriteLine("Name: {0} {1}", firstName, lastName);
}

The output is:
Name: ADAM Sutro
Name: Jim Carry

3.

where to use DOM parser and SAX parser

Answer»

The DOM Approach is USEFUL for small documents in which the program needs to PROCESS a LARGE portion of the DOCUMENT whereas the SAX approach is useful for large documents in which the program only needs to process a small portion of the document.

4.

Find XML Attribute and Element in below XML

Answer»

Find XML ATTRIBUTE and ELEMENT in below XML
Below is the example of XML and define where Attribute and Element is



XML Attribute Element

In above XML FIRST line have "Name" is attribute as i have copied the line in below image



XML Attribute

and in 6th line "Name" is and element i have copied the line in below image is and element in XML



XML Element

5.

Can we use graphics in XML if yes then how?

Answer»

Can we use graphics in XML if yes then how?
ANswer is Yes we can use graphics in XML by USING XLink and XPointer specifications. It will support graphic file FORMAT like GIF, JPG, TIFF, PNG, CGM, EPS and SVG.
Below is the example for the same



xml grahics

6.

Is it possible to execute XML?

Answer»

Is it possible to execute XML?
ANSWER is no we cannot execute XML because it is not a programming language to execute. It is just markup language only to REPRESENT data.

7.

Web architecture of XML Database

Answer»

web architecture of xml is too simple a client send a request to the server in a predefined format and receives the APPROPRIATE response. This is possibly because the data stored in an XML document does not assume its INTENDED use. Different applications can extract data according to their customized NEEDS. Since XML is USED to exchange data between various web applications, the coupling between the server applications and the client applications is relatively loose. XML can encode non-relational data, as well as relational data STRUCTURE. This enables the server applications to extract data from any data source, and helps the programmers to quickly build applications for the manipulations of that data.

xml architecture

8.

Difference between XML and HTML

Answer»

(1)HTML is mainly concern with displaying information on other hand XML is about describing information.
(2)HTML is called as a PRESENTATION language on other side XML is not a programming language nor a presentation language. It is used to transfer data between applications and databases.
(3)HTML is not case-sensitive on ther side XML is case-sensitive.
(4)In XML it is mandatory to close all the open tags but in HTML it is not required.
(5)XML was designed to describe data and to focus on what data is. HTML was designed to display data and to focus on how data LOOKS .
(6)White SPACES is preserved in XML files as compare to HTML.
(7) In XML data is stores in separate file on other side HTMLstores inside the files.
(8)To do some formatting realted to text and display in HTML we use CSS but in XML we use XSL.