XML

The Xml control is a control used to configure XML files as data sources. XML files are structured documents in which the XML schemas define the data layout and structure of the document. To perform its tasks, this control utilizes the functions contained in the classes, belonging to the System.Data.Xml and System. Data. XmlSchema namespaces.

The XmlDataSource control provides a wizard to configure XML files into your application. The wizard provides the option to specify the XML data file as the data source for the XmlDataSource control. A user of this control can optionally specify additional files that are used to modify the XML files before they are used by the XmlDataSource control.

Table 8.5 lists some noteworthy properties of the XmlDataSource class:

Lets create an application that uses an XmlDataSource control to retrieve data into a Web application from an XML file and a GridView control to query the XmlDataSource control to display the data on the Web page, by performing the following steps:

1. Open Microsoft Visual Studio 2010.

2. Select the File → New → Web Site option from the menu bar on the Start page. The New Web Site dialog box appears.

3. Select the Visual C# → ASP.NET Empty Web Site template in the New Web Site dialog box.

4. Click the Browse button for location, and enter the name of the Web site such as XMLdataSourcecontrol in the text box to specify the location and name of the Web site.

5. Click the OK button to create the XMLdataSourcecontrol Web site.

6. Add a Web Form to the XMLdataSourcecontrol Web site.

7. Drag and drop one XmlDataSource and GridView control from the Data tab of the Toolbox on the Web Form.

8. Right-click the Web site name and select Add New Item option from the context menu.

The Add New Item Dialog box appears (Fig.ASP-8.20).

9. Select Visual C# → XML File (Fig.ASP-8.20).

10. Click the Add button, as shown in Fig.ASP-8.20:

Fig.ASP-8.20

11. Add the following code snippet in the XmlFile.xml file:

<Student>

<student Name="3ohn" Rollno="A001" Standard="X"/>

<student Name="David" Rollno="A002" Standard="XI"/>

<student Name="Lisa" ROllno="A00B" Standard="XII"/>

</Student>

12. Click the smart tag of the XmlDataSource control and click the Configure Data Source option in the XmlDataSource Tasks, as shown in Fig.ASP-8.21:

Fig.ASP-8.21

The Configure Data Source dialog box opens.

13. Click the Browse button.

The Select XML File dialog box appears.

14. Select the XmlFile.xml file from the Contents of folder pane.

15. Click the OK button.

The Data file text box now contains the name of the Xml file in the Configure Data Source dialog box.

16. Click the OK button in the Configure Data Source dialog box.

We at Transtutors.com are aware of the complexities of this topic, and therefore our online computer science tutors are available round the clock to help you. We offer a range of services which includes Online homework help and assignment help, to help students with the homework and assignments related to computer science

So if you are you in need of Homework Help/ C++Assignment Help? Our competent pools of statistics professionals are available 24*7 to give you a solution to your problem!