Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have textboxes that i save the text to an xml file.The first textbox goes into the element name and the second goes into the value so I want to be able to use any chars in these textboxes but i get errors saying The character ' ' hexadecimal value 0x20 cannot be included in a name.the one textbox is used for the namespace and the other for the value.I need to allow chars in the name.I am using XDocument and not XmlDocument

What I have tried:

i have looked on Google but all i find is how to remove chars not how to allow them.I tried it the way it is but if i enter chars then it throws exceptions.
Posted
Updated 14-Aug-18 8:03am
v3

1 solution

You're probably talking about a CDATA section. They can be used to store any text information you want without having to worry about escaping characters.

Google: "XML CDATA"[^]
 
Share this answer
 
Comments
Codingnow20 13-Aug-18 19:06pm    
Wow I never saw CDATA before but I am pretty to new to xml so thanks a lot
Codingnow20 14-Aug-18 9:34am    
Does CDATA allow for spaces ??
Dave Kreskowiak 14-Aug-18 9:54am    
What happened when you tried it?

You can put anything you want inside the CDATA section, the sole exception to that being the character sequence ]]>.
Codingnow20 14-Aug-18 13:57pm    
well i tried but it always gives me the error "names cannot start with<"
Codingnow20 14-Aug-18 13:59pm    
basically what i want to do is to enter any character into a textbox that becomes the element name and the other textbox will be its value.Maybe its not possible but i sure hope it is

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