I am trying to read data from an MS Project XML file. I have used the XML Schema Tool to generate a set of strongly typed classes based on the Microsoft Project 2007 XML Schema.
However, I ran into several issues. The xmlns property on the root node from the XML exported from MS Project does not match the XSD schema.
MS Project generates this XML:
<Project xmlns="http://schemas.microsoft.com/project">
Should be:
<Project xmlns="http://schemas.microsoft.com/project/2007">
If I try to deserialize with the incorrect xmlns it throws an exception:
<Project xmlns='http://schemas.microsoft.com/project'> was not expected.
If I fix the xmlns it throws the exception:
Instance validation error: '0' is not a valid value for ProjectTaskFixedCostAccrual.
So it appears that either the XML Schema Utility did not correctly generate the classes, or the Microsoft Project 2007 XML Schema is incorrect.
My question is, has anybody encountered this situation before? Are there better alternatives to parsing MS Project XML (besides interop)?
Possible solution…
The data I was trying to deserialize was serialized from another component in the same application. The generated XML did not set the <FixedCostAccrual> element for each task. I imported the XML into MS Project and exported it as XML. MS Project set the <FixedCostAccrual> value to 0 for each task when I exported. However, valid values are within the range 1-3.
Not sure why MS Project would set the default value to something outside the range, but the solution was to fix the component which generates the output XML.
I’m still not sure why it generates the XML with the wrong xmlns attribute though.