Skip to main content
Home Forums Silverlight Programming Programming with .NET - General "XMLException: FLYUNDER_NAV is an unexpected token"
2 replies. Latest Post by cmptr_man on August 6, 2008.
(0)
CmptrMan
Member
2 points
3 Posts
05-20-2008 5:21 PM |
I'm trying to load XML embedded in my HTML page into my Silverlight control using an XmlReader created from a StringReader. The "FLYUNDER_NAV" it is referring to is the ID of the <XML> tag. It says The expected token is or . Line 2, position 9. (yup...that's not a mistype...it looks like "whitespace" or "null" to me....) The XML looks like this: <XML id="FLYUNDER_NAV"> <LINK title="Customer Service" url="http://sea-dev-sbx-07/dept/custsvc" target="" />
I'm trying to load XML embedded in my HTML page into my Silverlight control using an XmlReader created from a StringReader. The "FLYUNDER_NAV" it is referring to is the ID of the <XML> tag. It says
The expected token is or . Line 2, position 9. (yup...that's not a mistype...it looks like "whitespace" or "null" to me....)
The XML looks like this:
<
</
It appears from the stack that the problem is happening at the System.Xml.XmlTextReaderImpl.ParseAttributes() routine in the System.Xml.XmlTextReaderImpl.ParseElement() routine. So it doesn't seem that it's able to successfully load the string in the XmlReader object--and that the problem really is with the ID attribute of the parent tag!! If I copy the XML from my web page into my Silverlight control and load it internally as a string, it works just fine...it's only when it retrieves it from the web page using the innerHTML or outerHTML of the HtmlElement.
This approach works just fine in other Silverlight controls I've written for this website. I know that the "unexpected token" exception usually means that there's an error in the XML document somewhere, but why would it be having a problem with the ID of the tag?
I've tried moving the ID to a parent element and then grabbing it's innerHTML property (essentially, getting an <XML> element with no ID)...but then the error says "XMLException: 0 is an unexpected token". There isn't a "0" anywhere in the tag...so what's it talking about?!?!
WTF!?!?!? Anyone have any clues? The XML all looks correct to me...I don't see any invalid characters or anything. I could really use some suggestions to try, if anyone can think of anything.
Yi-Lun L...
All-Star
25052 points
2,747 Posts
05-22-2008 12:40 AM |
Hello, how do you embed xml in html? I don't know any standard way to do this... Are you using Xml Data Islands as discussed in this thread? Anyway, please make sure the string you get from inner/outerHTML is a valid xml content.
cmptr_man
4 points
4 Posts
08-06-2008 3:05 PM |
Thank you for the reply...and my appologies for the late response. I originally posted this using an email address I don't check very often.
I couldn't tell from the link you included what an XML data island is, exactly, but what I'm doing is just embedding the XML directly into a hidden DIV tag. Special characters have already been removed to (TRY and) ensure that the XML is compliant and doesn't break my page. Yeah, it's probably not the most robust way to do it, but I'm developing it for a corporate intranet where I've been guaranteed a browser type and version.
Unfortunately since I originally posted this, my company decided that they weren't going to support SL 2 Beta on our network for the first release of our website. They're very leery of beta products from Microsoft, and refuse to use them. They're opting instead to hold out until the final release of the product. So I have some time to come up with a better way for SharePoint and Silverlight to play nicely together. I was thinking about possibly going the Web Service route, but initial testing with that method showed that my brower's security token wasn't getting passed on to SharePoint--I think because of the "double-hop" issue that I've seen documented elsewhere when Kerberos isn't turned on...which it's not on our network. This has bitten us in the butt on a few other projects in the past, and I can't help but think that it's something we'll eventually have to address down the road.
I would really love for someone to come up with a good way for Silverlight and SharePoint to work together. Security context within SharePoint is a must for any meaningful GUI done in Silverlight, so I will likely have to push to get Kerberos configured before I'll see any real progress in this endeavor.
Thanks again for the reply.-Dan