Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: Beginning ASP.NET 1.0
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 26th, 2004, 12:38 AM
Registered User
 
Join Date: Jan 2004
Location: Seattle, WA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tophat
Default 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
  #2 (permalink)  
Old January 26th, 2004, 09:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Is the '@' symbol required?

  #3 (permalink)  
Old January 26th, 2004, 10:18 PM
Registered User
 
Join Date: Jan 2004
Location: Seattle, WA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tophat
Default

The '@' symbol is how it is in the book, whether it is required, I'm not sure.

  #4 (permalink)  
Old January 27th, 2004, 10:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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?
  #5 (permalink)  
Old January 28th, 2004, 05:41 PM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
  #6 (permalink)  
Old January 29th, 2004, 02:30 AM
Registered User
 
Join Date: Jan 2004
Location: Seattle, WA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tophat
Default

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);

  #7 (permalink)  
Old September 2nd, 2005, 01:13 AM
Registered User
 
Join Date: Aug 2005
Location: baroda, gujarat, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
  #8 (permalink)  
Old August 17th, 2007, 06:09 AM
Authorized User
 
Join Date: Dec 2004
Location: Madurai, Tamil Nadu, India.
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

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.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with binding XMl data into nested repeater vishnu108mishra XML 0 November 19th, 2007 03:53 AM
Binding XML to a listbox bonekrusher ASP.NET 2.0 Basics 0 March 25th, 2007 09:20 AM
BINDING DATA WITH SIMPLE CONTROLS saraswathyrajaram ASP.NET 1.0 and 1.1 Basics 13 August 29th, 2006 04:09 PM
simple xml / xslt example needed badgolfer ASP.NET 1.0 and 1.1 Basics 2 January 21st, 2005 02:10 AM



All times are GMT -4. The time now is 02:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.