write key value pair XMl in c#

Hi Experts,
      I have xml written in the classic ASP and I need to write the same in the c#. Could you please help on this ?

      ' /////////////////            Key/Value XML      /////////////////
      str="<?xml version=""1.0"" encoding=""UTF-16"" ?><SessionData>"
      'XML escape any query strings.
      str = Replace(str, "&", "&amp;")

      I was trying below but it didn't work as getting many compile time error.

       StringBuilder sbmenuModelXML = null;
         sbmenuModelXML = new StringBuilder();

     sbmenuModelXML.Append("<?xml version=""1.0"" encoding=""UTF-16"" ?><SessionData>");
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What are the errors? I only can see one problem - C# uses different escaping method that VB. So, instead of
     sbmenuModelXML.Append("<?xml version=""1.0"" encoding=""UTF-16"" ?><SessionData>");

Open in new window

it should be
     sbmenuModelXML.Append("<?xml version=\"1.0\" encoding=\"UTF-16\" ?><SessionData>");

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
satmishaAuthor Commented:
Thanks zc2, it worked.

Only issue i found was like at the end my XML contains beginning and ending characters i.e. {} like in given XML. How could I get rid of them too..?

            <?xml version="1.0" encoding="UTF-16" ?><SessionData>
satmishaAuthor Commented:
its done i guess...I simply need to convert that to in string. Thanks Pal for your quick reply.
satmishaAuthor Commented:
Zc2 suggestion worked..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.