Data at the root level is invalid


  • Dear Developer I store the webservice XML output to String and Again convert this string to XML .I successfully convert XML output to String, but i got problem again converting same XML formated  string to XML.
    I share my code 
     webservice.Service1 objService1 = new webservice.Service1();
        String s = objService1.HelloWorld();  //Convert XML output into String  
        XmlDocument xd = new XmlDocument();

    I use LoadXML() method, but i got error "Data at the root level is invalid. Line 1 position 1." .

    I also use xdocument = xdocument.parse(s), but here also get same error Data at the root level is invalid. Line 1 position 1.

    Its greatful, if any body give right code to convert String To XML in c#. I am really not understand , where is wrong , and what right code for this......Please MSDN help me...........
    Thanks In advance

    Monday, May 23, 2011 6:30 PM

All replies

  • What's in "s"? It's unlikely to be XML.
    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Tuesday, May 31, 2011 3:49 PM
  • While calling method objService1.HelloWorld(),  you will get a string "Hello World" in 's', not XML output.
    Malayalam SMS Website http://aspspider.info/smsmallu
    Wednesday, June 01, 2011 12:35 PM