 |
BOOK: Beginning ASP.NET 1.0  | This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

January 26th, 2004, 12:38 AM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ch02 - Binding to a Simple XML Document
Last example of the chapter, artists.xml and datacontrol2.aspx. Have followed the code in the book and even copied the code from the examples but to no avail. Error message reads:
Server Error in '/' Application.
--------------------------------------------------------------------------------
This is an unexpected token. The expected token is 'EndElement'. Line 19, position 9.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: This is an unexpected token. The expected token is 'EndElement'. Line 19, position 9.
Source Error:
Line 8: string xmlFilename = @"C:\inetpub\wwwroot\begASPNET_C\ch02\artists.xml" ;
Line 9: DataSet newDataSet = new DataSet();
Line 10: newDataSet.ReadXml(xmlFilename);
Line 11: DataGrid1.DataSource = newDataSet;
Line 12: DataGrid1.DataBind();
Source File: c:\inetpub\wwwroot\begASPNET_C\ch02\datacontrol2.a spx Line: 10
Stack Trace:
[XmlException: This is an unexpected token. The expected token is 'EndElement'. Line 19, position 9.]
System.Xml.XmlTextReader.Read() +1056
System.Xml.XmlLoader.ReadCurrentNode(XmlDocument doc, XmlReader reader) +116
System.Xml.XmlDocument.ReadNode(XmlReader reader) +51
System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving) +1225
System.Data.DataSet.ReadXml(String fileName) +63
ASP.datacontrol2_aspx.Page_Load() in c:\inetpub\wwwroot\begASPNET_C\ch02\datacontrol2.a spx:10
System.Web.Util.ArglessEventHandlerDelegateProxy.C allback(Object sender, EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
Code looks like this:
<%@ Page Language="c#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Xml" %>
<script runat="server">
void Page_Load()
{
string xmlFilename = @"C:\inetpub\wwwroot\begASPNET_C\ch02\artists.xml" ;
DataSet newDataSet = new DataSet();
newDataSet.ReadXml(xmlFilename);
DataGrid1.DataSource = newDataSet;
DataGrid1.DataBind();
}
</script>
<html>
<head>
<title>Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
</body>
</html>
I am not seeing what the problem is, any ideas?
Thanks
Jon
|
|

January 26th, 2004, 09:58 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Is the '@' symbol required?
|
|

January 26th, 2004, 10:18 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The '@' symbol is how it is in the book, whether it is required, I'm not sure.
|
|

January 27th, 2004, 10:09 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Sorry, the '@' is required.
Here is how the book has it.
<%@ Page language="c#" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Xml" %>
<script language="c#" runat="server">
void Page_Load()
{
string xmlFilename = @"C:\BegASPNET\ch02\artists.xml";
DataSet newDataSet = new DataSet();
newDataSet.ReadXml(xmlFilename);
DataGrid1.DataSource = newDataSet;
DataGrid1.DataBind();
}
</script>
<html>
<head>
<title>Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server" />
</body>
</html>
Note the path in red. Also, did you make it a virtual directory?
|
|

January 28th, 2004, 05:41 PM
|
|
Registered User
|
|
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
We are getting this same error on our page.
What we are doing is running a DTS job in SQL Server that recreates the XML file every five minutes so that a list of news items is "refreshed."
Unfortunately, our users are sometimes hitting that page on our site at the exact same time the XML file is getting re-generated, so they temporarily get the same error you're describing.
Kind of drag but I guess the answer is: don't have the XML file physically open while you're also trying to load it via your code.
|
|

January 29th, 2004, 02:30 AM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What I did was to put it in Inetpub under wwwroot. The line that comes up red for me as an error is: newDataSet.ReadXml(xmlFilename);
|
|

September 2nd, 2005, 12:13 AM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by Tophat
Last example of the chapter, artists.xml and datacontrol2.aspx. Have followed the code in the book and even copied the code from the examples but to no avail. Error message reads:
Server Error in '/' Application.
--------------------------------------------------------------------------------
This is an unexpected token. The expected token is 'EndElement'. Line 19, position 9.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: This is an unexpected token. The expected token is 'EndElement'. Line 19, position 9.
Source Error:
Line 8: string xmlFilename = @"C:\inetpub\wwwroot\begASPNET_C\ch02\artists.xml" ;
Line 9: DataSet newDataSet = new DataSet();
Line 10: newDataSet.ReadXml(xmlFilename);
Line 11: DataGrid1.DataSource = newDataSet;
Line 12: DataGrid1.DataBind();
Source File: c:\inetpub\wwwroot\begASPNET_C\ch02\datacontrol2.a spx Line: 10
Stack Trace:
[XmlException: This is an unexpected token. The expected token is 'EndElement'. Line 19, position 9.]
System.Xml.XmlTextReader.Read() +1056
System.Xml.XmlLoader.ReadCurrentNode(XmlDocument doc, XmlReader reader) +116
System.Xml.XmlDocument.ReadNode(XmlReader reader) +51
System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving) +1225
System.Data.DataSet.ReadXml(String fileName) +63
ASP.datacontrol2_aspx.Page_Load() in c:\inetpub\wwwroot\begASPNET_C\ch02\datacontrol2.a spx:10
System.Web.Util.ArglessEventHandlerDelegateProxy.C allback(Object sender, EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
Code looks like this:
<%@ Page Language="c#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Xml" %>
<script runat="server">
void Page_Load()
{
string xmlFilename = @"C:\inetpub\wwwroot\begASPNET_C\ch02\artists.xml" ;
DataSet newDataSet = new DataSet();
newDataSet.ReadXml(xmlFilename);
DataGrid1.DataSource = newDataSet;
DataGrid1.DataBind();
}
</script>
<html>
<head>
<title>Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
</body>
</html>
I am not seeing what the problem is, any ideas?
Thanks
Jon
|
MEHUL PATELAI
|
|

August 17th, 2007, 05:09 AM
|
|
Authorized User
|
|
Join Date: Dec 2004
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Check whether the following syntax of the path is working or not, because the syntax for the path in c# is different
"C:\\inetpub\\wwwroot\\begASPNET_C\\ch02\\artists. xml"
or use the server.mappath option to detect the artists.xml...
Thanks and Regards,
Senthil Kumar M.
|
|
 |