How to write XmlSerializable ReadXml for WriteXml with Elements through C# .NET v3.5 -


I'm not really sure what the right questions to ask here, so I will try my best to present the scenario.

We have got a parent object with a list of the quantities of different dimensions. Let's assume that the original object says that its length, duration, etc.

We want to serialize it from XML, necessarily through WriteXml / ReadXml. I have written the Lichhex XML, there is no problem in it. Our test output shows something along these lines.

  & lt; ParentObject name = "such endache" & gt; & Lt; Quantity & gt; & Lt; Length value = "123.456" /> & Lt; Period value = "78.9" /> & Lt; / Quantity & gt; & Lt; / ParentObject & gt;   

It's obvious, of course. The point is, we are writing an element in the name of "quantity". It's written using WriteStartElement ("Quantity") and WriteEndElement (). So far good.

Now I am writing readXL to read the matter and I am reorganizing the object. When I try and try "ReadStartElement" ("Quantity"), then I have not found any error like "Element" quantities.

Notes about the nodes and going to the current node Until that point I've used GetAttribute () and that's it, as far as I can tell, our reader is still in an initial position, maybe?

Better reading or reader status than medium

It can not answer your question directly, but instead of writing your code and reading it, why not use System.Xml.Serialization.XmlSerializer to do all the work for you.

I recently discovered it myself and

I used the example on the basis of the code (Stuff = ParentObject):

  Accessories material = function Cut-State (); Streamer Writer Writer = New Streamer ("stuff.xml") for; X = New System.Xml.Serialization.XmlSerializer (stuff.GetType ()); X.Serialize (author, content); Writer.Close (); Streamer reader = new streamer ("stuff.xml"); X = new System.Xml.Serialization.XmlSerializer (typef (stuff)); Material Goods = (Content) x. Derrilize (Reader); Reader.Close ();    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -