Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Serialization problem

Serialization problem

Scheduled Pinned Locked Moved C#
helpxmljsonquestiondiscussion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yoyosh 0
    wrote on last edited by
    #1

    I have a very simple and short application, which is copy/pasted below. Serialization goes perfectly nice. The XML file is being created and it looks correct. The problem starts when trying to deserialize -> I get an error: Code: There is an error in XML document (1, 1). --------------------------------- This is the programme: [Serializable] publicclassData { [XmlArrayItem(typeof(string))] publicArrayList Pol = newArrayList(); [XmlArrayItem(typeof(string))] publicArrayList Eng = newArrayList(); [XmlArrayItem(typeof(string))] publicArrayList Ger = newArrayList(); } [Serializable] publicclassStoreHouse { [XmlArrayItem(typeof(Data))] publicArrayList DataList = newArrayList(); } Serialization part: Data d = newData(); d.Eng.Add("1"); d.Eng.Add("2"); d.Ger.Add("dadas"); d.Ger.Add("dsadsadAS"); d.Pol.Add("dasd"); d.Pol.Add("etrre"); d.Pol.Add("trtre"); sh.DataList.Add(d); Data d1 = newData(); d1.Eng.Add("1321"); d1.Eng.Add("2ds"); d1.Ger.Add("ddadadas"); d1.Ger.Add("dsa123123dsadAS"); d1.Pol.Add("das31231dasd"); d1.Pol.Add("et3213rre"); d1.Pol.Add("t131rtre"); sh.DataList.Add(d1); XmlSerializer s = newXmlSerializer(typeof(StoreHouse)); s.Serialize(new System.IO.StreamWriter(@"c:\a.xml"), sh); Deserialization part: XmlSerializer s = newXmlSerializer(typeof(StoreHouse)); sh = ((StoreHouse)s.Deserialize(new System.IO.StringReader(@"c:\a.xml"))); What do you think may be wrong? thank you very much in advance

    L 1 Reply Last reply
    0
    • Y Yoyosh 0

      I have a very simple and short application, which is copy/pasted below. Serialization goes perfectly nice. The XML file is being created and it looks correct. The problem starts when trying to deserialize -> I get an error: Code: There is an error in XML document (1, 1). --------------------------------- This is the programme: [Serializable] publicclassData { [XmlArrayItem(typeof(string))] publicArrayList Pol = newArrayList(); [XmlArrayItem(typeof(string))] publicArrayList Eng = newArrayList(); [XmlArrayItem(typeof(string))] publicArrayList Ger = newArrayList(); } [Serializable] publicclassStoreHouse { [XmlArrayItem(typeof(Data))] publicArrayList DataList = newArrayList(); } Serialization part: Data d = newData(); d.Eng.Add("1"); d.Eng.Add("2"); d.Ger.Add("dadas"); d.Ger.Add("dsadsadAS"); d.Pol.Add("dasd"); d.Pol.Add("etrre"); d.Pol.Add("trtre"); sh.DataList.Add(d); Data d1 = newData(); d1.Eng.Add("1321"); d1.Eng.Add("2ds"); d1.Ger.Add("ddadadas"); d1.Ger.Add("dsa123123dsadAS"); d1.Pol.Add("das31231dasd"); d1.Pol.Add("et3213rre"); d1.Pol.Add("t131rtre"); sh.DataList.Add(d1); XmlSerializer s = newXmlSerializer(typeof(StoreHouse)); s.Serialize(new System.IO.StreamWriter(@"c:\a.xml"), sh); Deserialization part: XmlSerializer s = newXmlSerializer(typeof(StoreHouse)); sh = ((StoreHouse)s.Deserialize(new System.IO.StringReader(@"c:\a.xml"))); What do you think may be wrong? thank you very much in advance

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      GOOGLE: MSDN C# XmlSerializer "error in XML document" :rolleyes:

      led mike

      Y 1 Reply Last reply
      0
      • L led mike

        GOOGLE: MSDN C# XmlSerializer "error in XML document" :rolleyes:

        led mike

        Y Offline
        Y Offline
        Yoyosh 0
        wrote on last edited by
        #3

        I read many MSDN articles regarding serialization issue. I still can`t see mistake. Can you?

        L 1 Reply Last reply
        0
        • Y Yoyosh 0

          I read many MSDN articles regarding serialization issue. I still can`t see mistake. Can you?

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          -Yoyosh- wrote:

          I read many MSDN articles

          I don't care how many you read did you read the "one" that I pointed you to? The first one in the search results using my search? Did you read the section titled "Problems Deserializing XML"? If you did all that why have you not posted the contents of the InnerException so we can help you?

          led mike

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups