liberty4all
Programmer
Hi,
I am trying to use XML to display tables on my website, in hope it's faster than using a dataReader or dataSet.
The way I do it is using 3 files:
1. myxsl.xsl - an XSL file that defines how the XML should look like. It is well formed.
2. mysource.aspx - an ASPX file that just selects the data from the database like this:
3. myfile.aspx - an ASPX file that uses an XML data island and has all of the site's banners/menus and so on.
My problem is that my main page doesn't always load! It could load, and then I'd hit refresh 4-5 times and it would get stuck. That doesn't happen with mysource.aspx, it always load.
Any idea what could cause that? Could the code looking for a parseError be causing it? Maybe I should be going in a different way to accomplish this?
This is the url to the page incase you wanna see it..
Thanks... sorry for the long post
I am trying to use XML to display tables on my website, in hope it's faster than using a dataReader or dataSet.
The way I do it is using 3 files:
1. myxsl.xsl - an XSL file that defines how the XML should look like. It is well formed.
2. mysource.aspx - an ASPX file that just selects the data from the database like this:
Code:
void Page_Load(object sender, EventArgs e)
{
SqlConnection dbConnection = new System.Data.SqlClient.SqlConnection((string)Application["connStr"]);
string queryString = @"Select ... for xml raw";
System.Data.SqlClient.SqlCommand dbCommand = new System.Data.SqlClient.SqlCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;
dbCommand.CommandType = CommandType.Text;
Response.ContentType = "text/xml";
dbConnection.Open();
XmlReader reader = dbCommand.ExecuteXmlReader();
Response.Write(@"<?xml version='1.0' encoding = 'UTF-8'?> <?xml-stylesheet type='text/xsl' href=myxsl.xsl'?><records>");
reader.MoveToContent();
while (!reader.EOF)
{
Response.Write(reader.ReadOuterXml());
}
Response.Write("</records>");
reader.Close();
dbConnection.Close();
reader=null;
dbConnection=null;
}
Code:
<script runat="server">
//some C# code...
</script>
<script language="vbscript">
sub window_OnLoad()
set docTbl = CreateObject("MSXML2.DOMDocument.4.0")
docTbl.loadXML dsoTbl.XMLDocument.Xml
set docStyle = CreateObject("MSXML2.DOMDocument.4.0")
docStyle.async=false
docStyle.load "myxsl.xsl"
set docTarget = CreateObject("MSXML2.DOMDocument.4.0")
docTbl.transformNodeToObject docStyle, docTarget
if docTbl.parseError.errorCode <> 0 then
MsgBox docTable.parseError.reason
else
display.InnerHTML = docTarget.Xml
end if
end sub
</script>
<html>
<xml id="dsoTbl" href="myxsl.xsl" src="mysource.aspx">
</xml>
<head>
<body>
<!--somewhere in the HTML i have this line-->
<div id="display"></div>
</body>
</html>
My problem is that my main page doesn't always load! It could load, and then I'd hit refresh 4-5 times and it would get stuck. That doesn't happen with mysource.aspx, it always load.
Any idea what could cause that? Could the code looking for a parseError be causing it? Maybe I should be going in a different way to accomplish this?
This is the url to the page incase you wanna see it..
Thanks... sorry for the long post