XMLDocument.LoadXML(mystring)

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Hi I'm trying to use the loadXML method of the
XMLDocument but i'm recieving the following error.

'<', hexadecimal value 0x3C, is an invalid attribute
character

I have a <br> tag in my string which is causing the
problem, does anyone know how i can get around this?

Thanks
N
 
Either change it to <br/> so it's a valid tag, or replace the < with an
entity like &lt;

Otherwise you'll need to drop the text in a CDATA section.
 
Hi,

Thanks for your reply.

I have tried escaping the <br/> tag and using &lt; &gt;
syntax but this doesn't work. I can't use [CDATA because
this will render the <br> as text rather than a line
break. I think the problem is the less than sign < is not
accepted by the loadxml method, i need to find an
alternative way to represent this. Also i have tried
using &62# style syntax and this doesn't work either.

Do you have any more ideas?

Thanks
 
The original error you posted means that < is not allowed in an attribute,
you need to escape your attribute values (and make sure the names are
valid). Like this:

<tag attribute=">Won't Work<" />

needs to be escaped:

<tag attribute="&gt;This will&lt;" />

Or maybe you're even trying to declare an attribute with < in the name, like
this:

<tag <attribute="" />

Jerry

Neil said:
Hi,

Thanks for your reply.

I have tried escaping the <br/> tag and using &lt; &gt;
syntax but this doesn't work. I can't use [CDATA because
this will render the <br> as text rather than a line
break. I think the problem is the less than sign < is not
accepted by the loadxml method, i need to find an
alternative way to represent this. Also i have tried
using &62# style syntax and this doesn't work either.

Do you have any more ideas?

Thanks
-----Original Message-----
Either change it to <br/> so it's a valid tag, or replace the < with an
entity like <

Otherwise you'll need to drop the text in a CDATA section.




.
 
Back
Top