none
There is an error in XML document (3, 2). RRS feed

  • Question

  • Hey,

    I'm deserializing xml sitemap via  xsd tool but i got the below error 

    There is an error in XML document (3, 2).

    Any help please regarding this error

    thanks & regards

                   
    publicvoid LoadFromFile(string xml)
           {
               string FileName ="Web.sitemap";
           string path = Path.Combine(Environment.CurrentDirectory, @"Web.sitemap");
           try
           {XmlSerializer deserializer = newXmlSerializer(typeof(siteMap));
               TextReader reader = newStreamReader(path);
               object obj = deserializer.Deserialize(reader);
               siteMap XmlData = (siteMap)obj;
     
     
               //this.dgSiteMap.DataSource =  XmlData.Items[0].siteMapNode1;
               reader.Close();
     
    }
    catch (Exception ex)
    {
        
        throw ex;
    }
      
           }

    Tuesday, July 15, 2014 2:58 PM

Answers

  • Hello,

    I think if you could provide your XML file, XSD file and the sitemap class, we could help you better. For now, according your current information, what we can do is to give your some suggestions for this error:

    Have you tried using XmlSerializer to Serialize your stiemap object so you can compare the generated XML file with the one which you want to deserialize?

    You will have to look at the base exception to find out the problem. The exception caught probably contains 4 or more inner exceptions as:

    try
    
    {
    
      ...
    
    }
    
    catch (Exception ex)
    
    {
    
      Console.WriteLine(ex.GetBaseException());
    
    }
    

    You could also have a try with LINQ2XML to generate your object from the XML file, it is very simple:

    http://www.codeproject.com/Tips/366993/Convert-XML-to-Object-using-LINQ

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, July 16, 2014 2:37 AM
    Moderator