sp; while (node != null)
{
ShowDocument(node);
node = node.NextSibling;
}
}
}
// Format the output
private void Format (XmlNode node)
{
if (!node.HasChildNodes)
{
outputXml.Append(" " + "<" + node.Value + ">");
}
else
{
outputXml.Append("<" + node.Name + ">");
if (XmlNodeType.Element == node.NodeType)
{
XmlNamedNodeMap map = node.Attributes;
foreach (XmlNode attrnode in map)
outputXml.Append(" " + attrnode.Name + "<" + attrnode.Value + "> ");
}
outputXml.Append(" ");
}
}
}
下面就是webform2.aspx了
webform2.aspx
---
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Assembly Name="System.Xml" %>
<%@ Import Namespace="System.Xml" %>
<%@ Page Language="C#" Inherits="WebForm2" Src="WebForm2.cs" Debug="true" %>
<HTML><HEAD>
<script runat="server" language="C#">
// Put page script here
public void On_KeyUp(object sender, System.EventArgs e)
{
Response.Write("Works");
}
</script>
<!--<link REL="STYLESHEET" HREF="default.css" TYPE="text/css">-->
<TITLE>test</TITLE>
</HEAD>
<BODY >
<form method="post" action="WebForm2.aspx" runat="server" enctype="multipart/form-data">
<div align="left">
<table>
<tr>
<td>XML Document:</td>
<td><input type=file id="XmlFile" runat=server> FileName:</td>
<td><asp:label id="FileLabel" runat="server"></asp:label></td>
</tr>
<tr>
<td>XPath Expression</td>
<td><asp:textbox id=TextBox1 runat="server" Height="20" Width="300" text=".//text()"
OnKey_Up="On_KeyUp"></asp:textbox></td>
<td><asp:button type=submit OnClick="Query_Click" runat="server" Height="20" Width="91"
text="Query"></asp:button></td>
</tr>
</table>
</br>
<table>
<tr><td>Output from Query</td><td>XML Data</td><tr>
<tr><td>Query Display: <asp:dropdownlist runat="server">
<asp:listitem>Descriptive</asp:listitem>
<asp:listitem>XML</asp:listitem>
</asp:dropdownlist>
</td><tr>
<tr>
<td width="50%" valign="top" align="left"><asp:textbox id=TextBox2 runat="server" Height="400"
Width="350" TextMode="MultiLine" Rows="10"></asp:textbox></td>
<td width="50%" valign="top" align="left"><asp:xml id="MyXml" transformsource="test.xsl"
runat=server/></asp:xml></td>
</tr>
</table>
</div>
<td><asp:textbox id=TextBox3 runat="server" Height="1" Width="5" TextMode="MultiLine"
Rows="110"></asp:textbox></td>
</form>
</BODY>
</HTML>
{
ShowDocument(node);
node = node.NextSibling;
}
}
}
// Format the output
private void Format (XmlNode node)
{
if (!node.HasChildNodes)
{
outputXml.Append(" " + "<" + node.Value + ">");
}
else
{
outputXml.Append("<" + node.Name + ">");
if (XmlNodeType.Element == node.NodeType)
{
XmlNamedNodeMap map = node.Attributes;
foreach (XmlNode attrnode in map)
outputXml.Append(" " + attrnode.Name + "<" + attrnode.Value + "> ");
}
outputXml.Append(" ");
}
}
}
下面就是webform2.aspx了
webform2.aspx
---
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Assembly Name="System.Xml" %>
<%@ Import Namespace="System.Xml" %>
<%@ Page Language="C#" Inherits="WebForm2" Src="WebForm2.cs" Debug="true" %>
<HTML><HEAD>
<script runat="server" language="C#">
// Put page script here
public void On_KeyUp(object sender, System.EventArgs e)
{
Response.Write("Works");
}
</script>
<!--<link REL="STYLESHEET" HREF="default.css" TYPE="text/css">-->
<TITLE>test</TITLE>
</HEAD>
<BODY >
<form method="post" action="WebForm2.aspx" runat="server" enctype="multipart/form-data">
<div align="left">
<table>
<tr>
<td>XML Document:</td>
<td><input type=file id="XmlFile" runat=server> FileName:</td>
<td><asp:label id="FileLabel" runat="server"></asp:label></td>
</tr>
<tr>
<td>XPath Expression</td>
<td><asp:textbox id=TextBox1 runat="server" Height="20" Width="300" text=".//text()"
OnKey_Up="On_KeyUp"></asp:textbox></td>
<td><asp:button type=submit OnClick="Query_Click" runat="server" Height="20" Width="91"
text="Query"></asp:button></td>
</tr>
</table>
</br>
<table>
<tr><td>Output from Query</td><td>XML Data</td><tr>
<tr><td>Query Display: <asp:dropdownlist runat="server">
<asp:listitem>Descriptive</asp:listitem>
<asp:listitem>XML</asp:listitem>
</asp:dropdownlist>
</td><tr>
<tr>
<td width="50%" valign="top" align="left"><asp:textbox id=TextBox2 runat="server" Height="400"
Width="350" TextMode="MultiLine" Rows="10"></asp:textbox></td>
<td width="50%" valign="top" align="left"><asp:xml id="MyXml" transformsource="test.xsl"
runat=server/></asp:xml></td>
</tr>
</table>
</div>
<td><asp:textbox id=TextBox3 runat="server" Height="1" Width="5" TextMode="MultiLine"
Rows="110"></asp:textbox></td>
</form>
</BODY>
</HTML>