Articles: 843 | Categories: 148   
   
   
Home Articles Contact Us
 
 
 
 
Restructure XML with Transformation file in ASP.NET (0 Comments)
Admin: Posted Date: April 4, 2010

Shows how to restructure XML with Transformation files in ASP.NET.XML files can be structured differently. Some express properties of elements as attributes, whereas others express them as elements with inner text.

Restructure XML with Transformation file in ASP.NET


Shows how to restructure XML with Transformation files in ASP.NET

XML files can be structured differently. Some express properties of elements as attributes, whereas others express them as elements with inner text.
When working with the forementioned type of XML file (properties expressed as attributes), we are unable to access and display these attributes with such controls as the GridView. However, Visual Studio will enable us to transform the file so we can use it better.
This tutorial will show how we can create a Transformation file and use it to transform the XML file, so we can use all elements as originally intended.

We moved our web sites to Server Intellect and have found them to be incredibly professional. Their setup is very easy and we were up and running in no time.


An example XML file with properties expressed as attributes:

Pirates of Penzance
12.95
<:userComment rating="4">Best translation I've seen.
I like other versions better.
Being John Malkovich
24.95
Very good.
Excellent.
The Mist
24.95
Pretty good.

How NOT To Cook
23.95
Not bad.

James Bond; Casino Royale
29.95

I just signed up at Server Intellect and couldn't be more pleased with my Windows Server! Check it out and see for yourself.

We can use this as an XmlDataSource as normal, but in Visual Studio where it asks for Transformation file, we can creat a text file with the .xsl extension and point to it from the Configure Data Source window..
The XSL file will look something like this:


version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>

omit-xml-declaration="yes"
indent="yes"
standalone="yes" />



If you're looking for a really good web host, try Server Intellect - we found the setup procedure and control panel, very easy to adapt to and their IT team is awesome!

The ASPX file shows the difference in using the transformation file with a GridView control:




With Transformation File:








Without Transformation File: 

 

 

 
 
Add a Comment:
 
(You must be signed in to comment on an article. Not a member? Click here to register)
   
Title:

Comments: