Solved

This is an unexpected token.  Expected 'WHITESPACE'.  Line 2, position 62

Posted on 2004-05-03
8
1,917 Views
Last Modified: 2012-06-21
Hi Guys,

I have a program that reads some XML using XMLTextReader from an ASPX file.  Then assigns the XML to a TREEVIEW.TreeNodeSrc.  Then Databinds to render the TREEVIEW.

When I run the program on my local computer (just build and run it in VS.NET) the treeview correctly displays.  However when I run the program on our development server, I get the following error:

-------------------------------------------------------------------------------------
This is an unexpected token. Expected 'WHITESPACE'. Line 2, position 62.
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. Expected 'WHITESPACE'. Line 2, position 62.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:
[XmlException: This is an unexpected token. Expected 'WHITESPACE'. Line 2, position 62.]
   System.Xml.Schema.DtdParser.SkipWhitespace(Boolean fRequired) +147
   System.Xml.Schema.DtdParser.ParseExternalID() +484
   System.Xml.Schema.DtdParser.ParseDocTypeDecl() +347
   System.Xml.Schema.DtdParser.Parse() +61
   System.Xml.XmlTextReader.ParseDtd(XmlScanner scanner) +71
   System.Xml.XmlTextReader.ParseTag() +1442
   System.Xml.XmlTextReader.ParseRoot() +234
   System.Xml.XmlTextReader.Read() +127
   salesguides._default.GetXMLString()
   salesguides._default.Page_PreRender(Object sender, EventArgs e)
   System.Web.UI.Control.OnPreRender(EventArgs e) +67
   System.Web.UI.Control.PreRenderRecursiveInternal() +62
   System.Web.UI.Page.ProcessRequestMain() +1470

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.209; ASP.NET Version:1.0.3705.0
---------------------------------------------------------------------------------

Any ideas why it works on my local machine and not my development server?

Many thanks,
Dave.
0
Comment
Question by:tidydave
  • 5
  • 3
8 Comments
 
LVL 1

Expert Comment

by:asrinivask
ID: 10977292
can you please send the code snippet? Also, is the data same on both of your environments?
0
 

Author Comment

by:tidydave
ID: 10978393
Function GetXMLString() As String
        Dim BulidmenuPath As String
        Dim XMLString As String
        Dim wrRequest As WebRequest

        BulidmenuPath = ConfigurationSettings.AppSettings("serverlocation") & "/salesguides/bulidmenu.aspx?userid=" & Session("userid")
        wrRequest = WebRequest.Create(BulidmenuPath)

        Dim wrResponse As WebResponse = wrRequest.GetResponse()

        Dim objStream As Stream = wrResponse.GetResponseStream
        Dim objStreamReader As StreamReader = New StreamReader(objStream)

        XMLString = objStreamReader.ReadToEnd
        Return XMLString
    End Function

    Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
        Dim XML As String
        XML = GetXMLString()

        'Putting in this simple XML works!
        'XML = "<TREENODES><TREENODE TEXT=""TESTING""/></TREENODES>"

        Dim strBrowser As HttpBrowserCapabilities = Request.Browser
        Dim strVersion = strBrowser.MajorVersion & "." & strBrowser.MinorVersion
        Me.TreeView1.TreeNodeSrc = XML
        Me.TreeView1.DataBind()
        If strBrowser.Browser = "IE" And strVersion <= "5.5" Or Not strBrowser.Browser = "IE" Then
            Me.TreeView1.ExpandLevel = "1"
        End If
    End Sub
0
 

Author Comment

by:tidydave
ID: 10978409
Yes the data is the same on LOCALHOST and the development server.
0
 

Author Comment

by:tidydave
ID: 11047619
I will give this question a few more days then I'm going to ask for it to be deleted, as no one has pointed me in the right direction.  Thanks.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Accepted Solution

by:
asrinivask earned 500 total points
ID: 11049423
does your bulidmenu.aspx page contain the logic for creating the xml string for building the menu. I beleive that there is some problem with the xml string that is being built inside the GetXMLString method.
Can you let me know what is going on inside the bulidmenu.aspx page.
0
 
LVL 1

Expert Comment

by:asrinivask
ID: 11049472
or better can you also give that page's code
0
 

Author Comment

by:tidydave
ID: 11051407
Hi asrinivask!

The bulidmenu.aspx page simply creates an XML file... I have tested it on my localmachine and everything works.  I tested it by creating the most simple of XML files, like the one below:

<TREENODES><TREENODE TEXT="TESTING"/></TREENODES>

And it WORKS on my local machine.

But when I MOVE it to our development server the error occurs that I have stated earlier.

I have checked everything many times, there must be something different about the development server.   This is a weird error.
0
 

Author Comment

by:tidydave
ID: 11489032
Ok... the problem was that I had form authenication switched on.   So when the program executed bulidmenu.aspx it didn't return the XML it returned the login page!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now