ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication

Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Makeup Artist Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses


  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > Working with XML

ASP.NET Tutorial - Working with XML

                                                                                                                 Page 3 of 3


Example59: ReadSchemaFile.aspx

<%@ Import Namespace="System.Data" %>

<Script Runat="Server">

Sub Page_Load

Dim dstMenu As DataSet

dstMenu = New DataSet ()

dstMenu.ReadXml( MapPath( "SchemaFile.xml" ) )

rptItems.DataSource = dstMenu

rptItems.DataBind ()

End Sub





<asp: Repeater


Runat="Server" >




<br><%# Container.DataItem ( "Food" )%>

<p><b>Food Data Type:</b>

<br><%# Container.DataItem( "Food" ).GetType %>


<br><%# Container.DataItem( "Price" )%>

<p><b>Price Data Type:</b>

<br><%# Container.DataItem( "Price" ).GetType %>






The output is shown below: -

In the subroutine above, the ReadXml () method retrieves the SchemaFile.xml file into DataSet. The DataSet is then bound to a Repeater control, which displays the values of all the elements by using Repeaters.

Writing an XML Document from a DataSet

The DataSet classes include several methods for retrieving an XML representation of the data contained in a DataSet. If a string representation of XML data is to be retrieved the GetXml () method can be used as shown in the following example:-

Example60: GetMyXml.aspx

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.SqlClient" %>


<Script Runat="Server">


Sub Page_Load

Dim conNorthwind As SqlConnection

Dim dadEmployees As SqlDataAdapter

Dim dstEmployees As DataSet

Dim strXmlData As String


conNorthwind = New SqlConnection( "Server=localhost;UID=sa;PWD=secret;Database=Northwind" )

dadEmployees = New SqlDataAdapter( "Select * From Employees", conNorthwind )

dstEmployees = New DataSet()

dadEmployees.Fill ( dstEmployees, "Employees" )


strXmlData = dstEmployees.GetXml()

Response.Write( "<pre>" & Server.HtmlEncode( strXmlData ) & "</pre>" )

End Sub




The output is shown below: -

In the above example, the DataSet is dealing with Employees table of Northwind database of SqlServer. After employees table is added to the DataSet, the GetXml () method retrieves a string that contains an XML representation of the DataSet. This string is assigned to a variable named strXmlData and output is obtained using the Response object.


Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
© ExpertRating 2015. All Rights Reserved.