Click here to Skip to main content
14,084,501 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hello Everyone,

I am getting the below error
'<', hexadecimal value 0x3C, is an invalid attribute character. 


I have the xml File as follows.
<COLUMN INDEX="40" NAME="Session Configuration Success Rate (< 95%)"  TYPE="INTEGER" PROPERTYNAME="Scsr95Per"></COLUMN>

I dont want to remove the < sign from the xml.If i remove , it works for me .
Please give me other option.

I am getting the error in the given line.
How to solve it ?
Please guide me.

Thanks
Harshal
Posted
Updated 3 days ago
v3
Comments
phil.o 11-Jun-14 6:25am
   
< and > have a special meaning in XML; they are used to define tags.
So you cannot use them elsewhere as is, you have to escape them, as Richard told you in Solution 1.
< becomes &lt;
> becomes &gt;
& becomes &amp;
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try
<column index="40" name="Session Configuration Success Rate (&lt; 95%)" type="INTEGER" propertyname="Scsr95Per"></column>
   
Comments
R Harshal 11-Jun-14 6:33am
   
I am reading the Name from excel which must be same.
In my Excel file, column name is: Session Configuration Success Rate (< 95%)
And the same Name i have paste to the xml file :Session Configuration Success Rate (< 95%).As i am not getting the error for greater than sign .I am getting error only for this statement.
Should i need to change the column name in Excel.O do you have any other option.
please let me know.
Thanks
HArshal
Richard MacCutchan 11-Jun-14 7:41am
   
Well, as both I and phil.o pointed out, you cannot use special characters inside XML data, so you will need to change it after you read it in. I don't know what language you are coding in, but there may be a method that will do it for you.
R Harshal 12-Jun-14 10:11am
   
Thanks for your reply.
Thank you very Much.
Harshal
R Harshal 16-Jun-14 10:05am
   
Thanks for your answer .
Thank you very much.
Harshal
R Harshal 16-Jun-14 10:06am
   
Thanks you Richard and phil.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

instead of checking for every possible combination, use special methods to encode string to html (like System.Web.HttpUtility.HtmlEncode() in .Net).

Search and change any special code it finds to HTML equiv.

System.Web.HttpUtility.HtmlEncode("x < 80") = "x < 80"
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190518.1 | Last Updated 15 May 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100