views:

51

answers:

1
        reader.MoveToContent();
        var xs = new XmlSerializer(typeof(DerivedTypePackage<ScriptExecutionTask>[]));
        var packagedTasks = xs.Deserialize(reader.ReadSubtree()) as DerivedTypePackage<ScriptExecutionTask>[];
        reader.ReadEndElement();

After calling xs.Deserialize(reader.ReadSubtree()), the reader is pointing at the end element for ArrayOfDerivedTypePackageOfScriptExecutionTask, and it's returned an array. Seems to be working fine, except that the array only contains one element. Checking the XML, there are multiple DerivedTypePackageOfScriptExecutionTask nodes, but it seems like they're getting skipped. Why?

A: 

Without looking at all of the code or XML I believe the problem is the fact that ReadSubtree() will only read the first element which is a match. So, as you say it seems to be working fine, except that the array only contains one element. Would the one element be the first matching element in the XML document? If so I think this is your issue.

The example in the following MSDN documentation link shows how the ReadSubtree() method works. You will notice that they first read a node, then skip down and then the ReadSubtree() method will read the second node on their example xml and nothing more.

ReadSubtree() on MSDN

Hope this helps you out!

Tim C