469,286 Members | 2,522 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Encountering Error: This is an unexpected token. The expected token is 'NAME'.


I have a class that defines a Key/Name value collection that i
generated by and XML Element with multiple attributes. The attribute
are used to create the collection of 'Binate' objects. This is writte
in VB.NET 1.1.

I have this class in a Win32 test application and it works fine. Whe
I put the class in a Web app I get the following error. The assembl
it is in is not directory in the ASP.NET application but in one tha
the ASP.NET application references.

Here is an example of the code that accepts an XML Text Stream t
create the collection of Binate objects.

Public Sub New(ByVal XMLString As String, _
Optional ByVal XMLElement As String = "data")
Dim _xmlDoc As New XmlDocument
Dim _xmlNode As XmlNode
Dim _xmlAttr As XmlAttribute
Dim lp As Integer

Binates = New Collection

If (XMLString Is Nothing) Then
Throw New Exception("XML Stream is not defined")
End If
XMLString = XMLString.Trim()

If (XMLString.Length = 0) Then
Throw New Exception("XML String must contain a vali
XML string")
End If

***************************
*** Error is thrown here
_xmlDoc.InnerXml = XMLString
***************************
_xmlNode = _xmlDoc.SelectSingleNode(XMLElement)

For lp = 0 To _xmlNode.Attributes.Count - 1
_xmlAttr = _xmlNode.Attributes(lp)
Dim _binate As New Binate
_binate.Key = _xmlAttr.Name
_binate.Value = _xmlAttr.Value
Binates.Add(_binate)
_binate = Nothing
Next

End Sub

Where noted the following exception is thrown:
This is an unexpected token. The expected token is 'NAME'. Line 1
position 40.

I only get this when in the Web application and I have moved this clas
to the web assembly, the business assembly and into two seperate tes
programs. It works in the Win32 but not in the Web.

Any ieas

--
SaCompGee

I have been a computer geek for over 20 years. Currently using .NE
Usinging C# and VB and SQLServ
-----------------------------------------------------------------------
SaCompGeek's Profile: http://www.msusenet.com/member.php?userid=292
View this thread: http://www.msusenet.com/t-187089491

Nov 12 '05 #1
2 15818
SaCompGeek wrote:
Where noted the following exception is thrown:
This is an unexpected token. The expected token is 'NAME'. Line 1,
position 40.


Looks like your XML is malformed. Why don't you see what is at position
40 in line 1?

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.xmllab.net
http://blog.tkachenko.com
Nov 12 '05 #2

Oleg, thanks for the reply.

You are correct in that it was malformed but there is no line 40 whic
threw me off. Here is the XML that I thought I was testing:

<?xml version="1.0" encoding="us-ascii"?>
<data isAGoodDay="Yes" badDayTomorrow="Yes" chanceOfRain="70
suggestions="" />

but here is what was really being used:

<?xml version="1.0" encoding="us-ascii"?>
<dat
isAGoodDay="Yes"badDayTomorrow="Yes"chanceOfRain=" 70"suggestions="" />

No spaces betweem the attributes made it barf.
Thanks again, Shaw

--
SaCompGee

I have been a computer geek for over 20 years. Currently using .NE
Usinging C# and VB and SQLServ
-----------------------------------------------------------------------
SaCompGeek's Profile: http://www.msusenet.com/member.php?userid=292
View this thread: http://www.msusenet.com/t-187089491

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Bob Stearns | last post: by
5 posts views Thread by cranium.2003 | last post: by
8 posts views Thread by Brian Tkatch | last post: by
4 posts views Thread by lisa | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.