Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
4.00/5 (1 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 15-May-19 13:41pm
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;

Try
XML
<column index="40" name="Session Configuration Success Rate (&lt; 95%)" type="INTEGER" propertyname="Scsr95Per"></column>
 
Share this answer
 
Comments
[no name] 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.
[no name] 12-Jun-14 10:11am    
Thanks for your reply.
Thank you very Much.
Harshal
[no name] 16-Jun-14 10:05am    
Thanks for your answer .
Thank you very much.
Harshal
[no name] 16-Jun-14 10:06am    
Thanks you Richard and phil.
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"
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900