c# - Convert string to XML using .Net -


i store xml output string , again convert string xml .i convert xml output string, got problem again converting string xml.

sample code:

 webservice.service1 objservice1 = new webservice.service1();     string s = objservice1.helloworld();   //convert xml output string        xmldocument xd = new xmldocument();     xd.loadxml(s); 

i use loadxml() method, got error

data @ root level invalid. line 1 position 1. 

its grateful, if body give right code convert string xml in c#. thank you,

you should use xdocument. xdocument better xmldocument. efficient, simple , easy use.

your code :

webservice.service1 objservice1 = new webservice.service1();     string s = objservice1.helloworld();   //convert xml output string        xmldocument xd = new xmldocument();     xd.loadxml(s); 

solution:

xdocument xd = xdocument.parse(s); 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -