views:

303

answers:

1

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"&gt;

Should be:
<Project xmlns="http://schemas.microsoft.com/project/2007"&gt;

If I try to deserialize with the incorrect xmlns it throws an exception:

<Project xmlns='http://schemas.microsoft.com/project'&gt; 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)?

A: 

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.

Kevin
Maybe the component is compatible with the previous version of Project? Maybe you've got the schema for the new version, but data from the old version?
John Saunders
Both components are designed to work with MS Project 2007 but if you export a document in 2007 as XML, the xmlns attribute is incorrect according to the 2007 XSD. It's possible it does that so the same data can be used in older MS Project versions though, I'll have to see if there's any compatibility options I can disable.
Kevin