This site has been taken over by the staff of www.ASPDeveloper.Net

Please report errors to suggest@aspdeveloper.net

BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
.NET and XML
Returning Raw XML
Populating a TreeView Control
Handling Events
Data with a TreeView
ASP.NET XML Architecture
Code to create entire file system as XML File in VB.NET
Class object for Base64 conversion with .NET
XML Web Services and ASP.NET
String Handling Application using ASP.NET
XML Serialization and .Net
Dynamic Method Invocation in .NET using Reflection API
Using XML classes in .Net
Pass node sets to XSLT stylesheets using .NET
Output a directory as XML using .NET
.Net, COM Interoperability and Word Object Model
WS-Routing for .NET endpoints
Using XML and XSLT in VB.NET Jeopardy
Symmetric Encryption/Decryption with .NET
XInclude.NET 1.0
EXSLT.NET 1.0
<< XSLT
 

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :2796

 

XML Web Control

The first scenario where we can leverage ASP.NET inside an XML-enabled application was very much geared towards automatic data exchange. Human users typically do not care that much about seeing raw XML. My barely computer literate parents for example would be very confused if they go to the internet to book an airline ticket and the web site would display their itinerary in XML format. They would much rather see a nicely formatted web page which shows their travel data in an easy to read format.

Big deal, you could say, you can transform the XML into HTML with an XSLT stylesheet, you already showed us how to accomplish that with the classes in System.Xml.Xsl: We load the XML data into a System.Xml.XPath.XPathDocument and then perform the transformation with a System.Xml.Xsl.XslTransform object. And while you could certainly do it that way, ASP.NET makes it is even easier than that. The ASP.NET Framework provides the Xml Web Control that does all this for us. The XML control is represented by the <asp:Xml> tag in an ASP.NET page, which we can either write into the page code ourselves, or we can let the Web Forms designer insert it. We just need to associate the XML data and the transformation, which is optional, with the XML Web Control and the magic happens. We can associate the data and the transformation in two ways: Programmatically through properties of the control class or through attributes of the <asp:Xml> tag. Setting them programmatically offers a few more options than setting the tag attributes. Table 17.1 lists all the attributes and properties.

1.1            Table 17.1: You can specify the XML data source and the XSLT transformation for the Xml Web Control  by setting properties on the web control object in the ASP.NET page. Some properties double up as attributes you can set directly on the <asp:Xml> tag.

Property

Attribute

Description

System.Xml.XmlDocumentation
Document

 { get; set }

N/A

An XmlDocument object as the XML data source

string DocumentContent 
{ get; set }

No attribute, but you can embed the XML data within the <asp:Xml> tags

A string as the XML data source.

string DocumentSource

{ get; set }

DocumentSource

The path to a file containing the XML data source. The path has to be within the web application’s directory structure.

System.Xml.Xsl.XslTransform
Transform

{ get; set }

N/A

An XslTransform object as the source for the XSL transformation to apply to the XML data.

System.Xml.Xsl.XsltArgumentList TransformArgumentList

{ get; set }

N/A

The parameters to pass to the XSLT transformation when it is applied to the XML data. Passing parameters is optional.

string TransformSource

 { get; set }

TransformSource

The path to a file containing the XSL transformation to apply to the XML data. The path has to be within the web application’s directory structure.

Now we can actually write a short ASP.NET page that transforms the XML document from figure 17.6 to HTML with the Xml Web Control. The output of the page will display as shown in the graphic below:


Figure 17.7 Web page generated with the Xml Web control.


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Software Specialist, Linux - Finlan
Linux Core Technical Project Manage
Graphics designer at Tanzania. Expe
Integration Specialist Needed - Wor
Virtualization Server Infrastructur

View all Jobs (Add yours)
View all CV (Add yours)






    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP