Advertisement

06.03.2008 at 02:17PM PDT, ID: 23454766
[x]
Attachment Details

Problem loading XML with undeclared entity

Asked by andrewh123 in Extensible HTML (XHTML), Extensible Markup Language (XML), Programming for ASP.NET

Tags: xml, asp.net, Reference to undeclared entity 'nbsp'

Hi,
I have inherited some ASP.net code which takes text from textboxes and reads it in to a DB as XML.
Everything is fine when the text is "clean".  However, if I insert " " intot he text box, I get the following error:
Reference to undeclared entity 'nbsp'.

After some  searching on the web I get the following post which seems to be very helpful -
http://blogs.pingpoet.com/overflow/archive/2005/07/20/6607.aspx
However, this is well beyond my technical level and I can't really understand what to do!!

This is what I have:
            Dim aArticleContentDoc As New XmlDocument    

            aArticleContentDoc.LoadXml(articleContent)  ---- and this is where the crash happens

articleContent in the test that crashes = <userxml><title></title><html>Test&nbsp; 1</html></userxml>

strangely, other things like &amp; work fine.

What I need I think is either:
a) turn off whatever is causing the crash!
b) clean up the input
c) fix it properly!!

for b) I could simply so a replace on all &nbsp; which would fix this, but I don't know if it would happen again with something else (eg &ooops; breaks it too!)
Any help greatly appreciated.
Am running vb.net

Thanks
Andrew
Start Free Trial
 
Loading Advertisement...
 
[+][-]06.03.2008 at 05:15PM PDT, ID: 21705654

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Extensible HTML (XHTML), Extensible Markup Language (XML), Programming for ASP.NET
Tags: xml, asp.net, Reference to undeclared entity 'nbsp'
Sign Up Now!
Solution Provided By: ororiole
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.04.2008 at 01:08AM PDT, ID: 21707838

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 09:00AM PDT, ID: 21711398

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628