locked
error - Data at the root level is invalid. Line 1, position 1 RRS feed

  • Question

  • User647458646 posted

    I am currently experiencing error on the following code - i am not sure what's causing this error.  Please advice.  Many thanks. 

    error - Data at the root level is invalid. Line 1, position 1

    code line - var document = XDocument.Parse(articleABS());

           public string createURL()
            {
                string uri = "";
                
                var document = XDocument.Parse(articleABS());
                var href = document.Descendants("link").Single().Attribute("title").Value;
                href = href.Replace("Article", "");
                string id = Regex.Match(href, @"\d+").Value;
                var result = (@"#####");
                return uri = result.ToString();
            }
     public static string articleABS()
            {
                string URL = "#####";
                string method = "POST";
                string postData = template.createXMLArticle();
                string responseData = "";
                int statusCode;
    
                if (hwrequest.Method == "POST")
                {
                   ....
                }
                
                using (HttpWebResponse hwresponse = (HttpWebResponse)hwrequest.GetResponse())
                {
                    ....
                    }
    
                    hwresponse.Close();
                }
                return responseData;
            }

    Thank you

    Monday, June 20, 2016 3:43 PM

Answers