I have a very large, complex XML file and I wish to extract every element value to an object I already created. I have tried WCF DataContractSerializer and plain XmlSerializer which both were very problematic.
Other than using the above methods to parse my XML and assign to objects, can someone please recommend the easiest way to to achieve the above?
I was considering just using XDocument.
My ultimate goal is to take the values from the object and serialize to a new XML.
Here was my original post
XML deserialization to object error
DataContractSerializer and XmlSerializer can only hydrate XML into an object that you already have. Namely, they only work if you start with object of type X, serialize it, and then deserialize it back into type X. Generally, you use them if you are consuming a service that publishes a data contract, or if you are the one serializing the data yourself. Note that I said they serialize the entire object. That goes beyond just the data and includes the structure and types that the data fits into.
Since it’s not apparently a serialized object, you are on the right track with building your own object and using XDocument to pick it apart.