Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am unable to create XElement with the string which contains the unicode.

Below code is failing to create XElement. How can I create an XElement with the unicode.

C#
XDocument xDoc = new XDocument(

            new XElement("Pubs", 
                new XElement("Book", 
                    new XElement("Title", "Social Service"),
                    new XElement("Author", "Nagsert")),
                new XElement("Book",
                    new XElement("Title", "Self Motivation"),
                    new XElement("Author", "Srinu")
                    )
                )
        );
      // XElement String contains unicode
            xDoc.Root.Add(new XElement("Book",
          new XElement("Title", "Problem  Is Still Exist"),
            new XElement("Author", "Gazit, Inbar")
        ));e>


What I have tried:

I have gone thorough the unicode problems in c#.
I found that the unicode details for special character

Unicode character Oct Dec Hex HTML
Results 1 - 4 of 4
\x{15} nak negative acknowledge ctrl-u 025 21 0x15 
᷂ combining snake below 016702 7618 0x1DC2 ᷂
⺒ cjk radical snake 027222 11922 0x2E92 ⺒
𐂔 linear b monogram b128 kanako 0200224 65684 0x10094 𐂔
Posted
Updated 29-Sep-16 4:38am
v2

1 solution

You have to escape Unicode characters with &# when using them in XML.

Google is your friend.
 
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