I updated the question @ xml content changed after serialization & deserialization want to pass in xml to map object
Any help are appreciated. Thanks a lot.
I am new to all of these: I am trying to pass in an xml file from a webapplication browse button to a service, call and then run it.
I searched and did the following:
string InputFilePath = FileUpload1.PostedFile.FileName;
MyServiceTypeClass _MyServiceTestObj = new MyServiceTypeClass ();
XmlSerializer SerializerObj = new XmlSerializer(typeof(MyServiceTypeClass ));
StreamWriter WriteFileStream = new StreamWriter(@InputFilePath);
SerializerObj.Serialize(WriteFileStream, _MyServiceTestObj );
WriteFileStream.Close();
FileStream XmlStream = new FileStream(@InputFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
MyServiceTypeClass _ServiceTypeLoaded = (MyServiceTypeClass )SerializerObj.Deserialize(XmlStream);
XmlStream.Close();
After I run it and upload an xml file, I found that _ServiceTypeLoaded
fields are almost all null for the fields. And the xml file content has been changed after running the above lines.
_ServiceTypeLoaded
only has 3 fields not null
, and the xml file has changed to other format with lots of tags missing.
Some More Details:
MyServicetypeClass
structure:
MyServiceTypeClass
inherited from Class A and has some of its own members; Class A inherited form Class B and has some of its own members; Class B inherited from Class C and has some its own members etc. There are 5 layers in the relationship.