Solved

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

Posted on 2004-05-03
8
1,932 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using Classic ASP inside HTML pages 2 71
Button on Table, name table1 not working 4 34
Send form to asp server side 6 27
Ajax on ASP 2 41
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…

733 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