unable to convert xml to dataset Error: Illegal characters in path.
namespace MailFuntionality
{
    class Program
    {


        static EmailHelper emailHelper = new EmailHelper();
        static void Main(string[] args)
        {
            //string Date = SPUtility.CreateISO8601DateTimeFromSystemDateTime(getdate);
            string username = ConfigurationSettings.AppSettings["loginUser"].ToString();
            string domain = ConfigurationSettings.AppSettings["Domain"].ToString();
            string password = ConfigurationSettings.AppSettings["Password"].ToString();
            string webserevice = ConfigurationSettings.AppSettings["webserevice"].ToString();

            SharePointOnlineCredentials credentials = GetO365Credentials(username + "@" + domain, password);

            CookieContainer cc = GetO365CookieContainer(credentials, webserevice);
            MailFunctionality.Lists listService = new MailFunctionality.Lists();
            listService.Url = webserevice;
            listService.CookieContainer = cc;
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            string listName = "TestMail";
            // string viewName = "%7B2304B04C%2D4071%2D4BA0%2D786B%2D986633AD7823%7D";
            string rowLimit = "25000";
            System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
            System.Xml.XmlElement viewFields =
                xmlDoc.CreateElement("ViewFields");
            System.Xml.XmlElement queryOptions =
                xmlDoc.CreateElement("QueryOptions");
            /* CAML fragments to the InnerXml property of each element.*/
            // query.InnerXml = "<Leq><FieldRef Name='Remider_Date' /><Value Type ='DateTime'>" + Date + "</Value></Leq>";
            query.InnerXml = "";
            viewFields.InnerXml = "";
            queryOptions.InnerXml = "";
            System.Xml.XmlNode nodeListItems = listService.GetListItems(listName, null, query, viewFields, null, queryOptions, null);
            foreach (XmlNode node in nodeListItems)
                if (node.Name == "rs:data")
                    for (int f = 0; f < node.ChildNodes.Count; f++)
                    {
                        if (node.ChildNodes[f].Name == "z:row")
                        {
                            string title = node.ChildNodes[f].Attributes["ows_city"].Value;
                            string ID = node.ChildNodes[f].Attributes["ows_ID"].Value;

                            Console.WriteLine("Title of Task : " + title);
                        }
                    }
              var stringReader = nodeListItems.InnerXml.ToString();
                 WebClient web = new WebClient();
                 DataSet ds = new DataSet();
                 {
                     ds = new DataSet();
             
                    ds.ReadXml(stringReader);    (error illegal char in path)
  }
                 DataTable dt = ds.Tables[0];

    
            Console.ReadLine();

        }
        public static CookieContainer GetO365CookieContainer(SharePointOnlineCredentials credentials, string targetSiteUrl)
        {

            Uri targetSite = new Uri(targetSiteUrl);
            string cookieString = credentials.GetAuthenticationCookie(targetSite);
            CookieContainer container = new CookieContainer();
            container.SetCookies(targetSite, cookieString);
            return container;
        }

        public static SharePointOnlineCredentials GetO365Credentials(string userName, string passWord)
        {
            SecureString securePassWord = new SecureString();
            foreach (char c in passWord.ToCharArray())
                securePassWord.AppendChar(c);
            SharePointOnlineCredentials credentials = new SharePointOnlineCredentials(userName, securePassWord);
            return credentials;
        }

    }
August 20th, 2015 1:00am

Try:

 ds.ReadXml(new StreamReader(@"+stringReader+"System.Text.Encoding.UTF8));

OR

ds.ReadXml(@"+stringReader+");

Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 3:02am

Hi Vishal,

Please try to change your code like this:

DataSet ds = new DataSet();
StringReader sr = new StringReader(nodeListItems.OuterXml);
ds.ReadXml(sr);

https://social.msdn.microsoft.com/Forums/sharepoint/en-US/2fee44a9-a09e-4e35-9206-83931d542c12/list-items-webservice-to-datatable-traversing-xmlnode-childnodes-root-element-is?forum=sharepointdevelopmentlegacy

Best Regards,

Dennis

September 1st, 2015 1:34am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics