Note that there are some explanatory texts on larger screens.

plurals
  1. PODeserialization Xml Document Error
    primarykey
    data
    text
    <p>I have a problem when I deserialize the xml into List of Objects. I searched it on the net this morning, but my problem isn't resolved.</p> <p>Deserialization method </p> <pre><code>public static List&lt;FileAction&gt; DeSerialization() { XmlRootAttribute xRoot=new XmlRootAttribute(); xRoot.ElementName="ArrayOfSerializeClass"; xRoot.IsNullable=true; XmlSerializer serializer = new XmlSerializer(typeof(List&lt;FileAction&gt;),xRoot);//, new XmlRootAttribute("ArrayOfSerializeClass") using (Stream streamReader = File.OpenRead(@"C:\serialization\SerializationWithFileWatcher\Output\XmlSerialize.xml"))//FileStream fs =new FileStream(xmlPath,FileMode.Open) { using (XmlReader reader = XmlReader.Create(streamReader)) { int count =0; List&lt;FileAction&gt; serialList2 = (List&lt;FileAction&gt;)serializer.Deserialize(reader); return (List&lt;FileAction&gt;)serializer.Deserialize(reader); } } </code></pre> <p>Calling Method </p> <pre><code>String resultPath = @"C:\serialization\SerializationWithFileWatcher\Output\XmlSerialize.xml"; if (!File.Exists(resultPath)) { XmlSerializer xs = new XmlSerializer(typeof(List&lt;SerializeClass&gt;)); using (FileStream fileStream = new FileStream(@"C:\serialization\SerializationWithFileWatcher\Output\XmlSerialize.xml", FileMode.Create)) { xs.Serialize(fileStream, serializeList);//seri fileStream.Close(); } Console.WriteLine("Succesfully serialized to XML"); } else { //string path= @"C:\serialization\SerializationWithFileWatcher\Output\XmlSerialize.xml"; DeSerialization(); XmlSerializer xs = new XmlSerializer(typeof(List&lt;SerializeClass&gt;)); FileStream fs = new FileStream(@"C:\serialization\SerializationWithFileWatcher\Output\XmlSerialize.xml", FileMode.Append, FileAccess.Write); using (XmlWriter xwr = XmlWriter.Create(fs))//TextWriter xwr = new StreamWriter { xs.Serialize(xwr, serializeList);//seri //fs.Close(); } Console.WriteLine("Succesfully serialized to XML"); } return serializeList; </code></pre> <p>The reason why I am calling it here is that I want to add this object again to the xml file.</p> <p>THe error is that here is an error in XML document (15,27).</p> <p>My Xml structure </p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;ArrayOfSerializeClass xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;SerializeClass&gt; &lt;creationTime&gt;2013-11-25T09:53:25.3325289+05:30&lt;/creationTime&gt; &lt;fileAction&gt;Renamed&lt;/fileAction&gt; &lt;Properties&gt; &lt;FileAttributes fileName="validate json.txt"&gt; &lt;fileSize&gt;307&lt;/fileSize&gt; &lt;extension&gt;.txt&lt;/extension&gt; &lt;lastAccessTime&gt;2013-11-25T09:53:25.3325289+05:30&lt;/lastAccessTime &lt;fullPath&gt;C:\serialization\SerializationWithFileWatcher\SerializationWithFileWatcherProj\validate json.txt&lt;/fullPath&gt; &lt;/FileAttributes&gt; &lt;/Properties&gt; &lt;/SerializeClass&gt; &lt;/ArrayOfSerializeClass&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload