Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Navigate XML content
Message
From
27/08/2008 03:36:13
 
 
To
26/08/2008 23:19:37
General information
Forum:
ASP.NET
Category:
XML
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01341375
Message ID:
01342110
Views:
12
>Hi,
>What if I have xml like this
>
>
><?xml version="1.0" encoding="utf-8" ?>
><PlugInEvents>
>	<PlugInEvent>
>		<Name>Application.Startup</Name>
>		<Description>Occurred when application startup</Description>
>		<MustImplementTypes>
>			<MustImplementType>
>				<Type>IApplication</Type>
>				<EventHandler>Startup</EventHandler>
>				<Assembly>c:\\aaa.dll</Assembly>
>			</MustImplementType>
>		</MustImplementTypes>
>	</PlugInEvent>
>	<PlugInEvent>
>		<Name>Application.Shutdown</Name>
>		<Description>Occurred when application shutdown</Description>
>		<MustImplementTypes>
>			<MustImplementType>
>				<Type>IApplication</Type>
>				<EventHandler>Shutdown</EventHandler>
>				<Assembly>c:\\aaa.dll</Assembly>
>			</MustImplementType>
>			<MustImplementType>
>				<Type>IGlobal</Type>
>				<EventHandler>GlobalShutdown</EventHandler>
>				<Assembly>c:\\Global.dll</Assembly>
>			</MustImplementType>
>		</MustImplementTypes>
>	</PlugInEvent>
></PlugInEvents>
>
>
>And I want to show them like this:-
>
>
>Name: Application Startup
>Description: Occurred when application startup
>Must Implement:
>    Type: IApplication
>    EventHandler: Startup
>    Assembly: c:\\aaa.dll
>
>Name: Application Shutdown
>Description: Occurred when application shutdown
>Must Implement:
>    Type: IApplication
>    EventHandler: Shutdown
>    Assembly: c:\\aaa.dll
>    Type: IGlobal
>    EventHandler: GlobalShutdown
>    Assembly: c:\\Global.dll
>
>
>Thank you

Hi,
You didn't specify where the output was going but here's an XSLT that should give you the format want:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/PlugInEvents">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="PlugInEvent">
 
Name: <xsl:value-of select="Name" />
Description: <xsl:value-of select="Description"/>
Must Implement:<xsl:apply-templates select="MustImplementTypes"/>
-----------------------------------------------------------------
</xsl:template>
<xsl:template match="MustImplementType">
  
    Type: <xsl:value-of select="Type"/>
    EventHandler: <xsl:value-of select="EventHandler"/>
    Assembly: <xsl:value-of select="Assembly"/>
</xsl:template>
</xsl:stylesheet>
and here's how to use it to output to a file:
System.Xml.Xsl.XslCompiledTransform xslt = new System.Xml.Xsl.XslCompiledTransform();
xslt.Load("Input.xslt");
xslt.Transform("input.xml", "output.txt");
Previous
Reply
Map
View

Click here to load this message in the networking platform