Retireve data from custom columns(extended attributes)

Hi,


I have created an xml from programatically with extended attributes. By opening this xml in MSP, I can see the new custom columns that I added as extended attributes. Now, I enter data into these columns in MSP and save. I am trying to read this mpp file in c# code. When I do that, I am unable to read values in the extended attributes. I am also not able to read the task that I entered in mpp.
Pls guide me accordingly.

Regards

Hi,


Thank you for writing to Aspose Support team.

We have tried to reproduce this issue using the following code sample and steps you have mentioned, but were not able to face the problem. Following are the steps we used for testing this issue:

1. Executed the following code to generate the XML file.

//Load an existing MPP blank project to which the Extended Attributes will be added
Project proj = new Project(@“Blank2010.mpp”);

//Create the Extended Attribute Definition of Text Type
ExtendedAttributeDefinition taskExtendedAttributeText9Definition;
taskExtendedAttributeText9Definition = new ExtendedAttributeDefinition();
taskExtendedAttributeText9Definition.Alias = “Task City Name”; //Display Name of the column for this extended attribute
taskExtendedAttributeText9Definition.FieldName = “Text9”;
taskExtendedAttributeText9Definition.ElementType = ElementType.Task;
taskExtendedAttributeText9Definition.CfType = CustomFieldType.Text;
taskExtendedAttributeText9Definition.FieldId = Convert.ToInt32(ExtendedAttributeTask.Text9).ToString(System.Globalization.CultureInfo.InvariantCulture);

//Create an Extended Attribute Definition of Flag Type
ExtendedAttributeDefinition taskExtendedAttributeFlag1Definition;
taskExtendedAttributeFlag1Definition = new ExtendedAttributeDefinition();
taskExtendedAttributeFlag1Definition.Alias = “Is Billable”;
taskExtendedAttributeFlag1Definition.FieldName = “Flag1”;
taskExtendedAttributeFlag1Definition.ElementType = ElementType.Task;
taskExtendedAttributeFlag1Definition.CfType = CustomFieldType.Flag;
taskExtendedAttributeFlag1Definition.FieldId = Convert.ToInt32(ExtendedAttributeTask.Flag1).ToString(System.Globalization.CultureInfo.InvariantCulture);

//Add the Extended Attribute Definitions to the Project’s Extended Attribute Collection
proj.ExtendedAttributes.Add(taskExtendedAttributeText9Definition);
proj.ExtendedAttributes.Add(taskExtendedAttributeFlag1Definition);

//Save the Project
proj.Save(“output2.xml”, SaveFileFormat.XML);

2. Opened the generated XML file from step 1 and added a task data along with extended attributes data using MSP.

3. Saved the XML file as MPP using MSP

4. Read the MPP file using the following code which displays the Task as well as Extended Attributes data.

Project project = new Project(file);

foreach (Task tsk in project.RootTask.Children)
{
foreach (ExtendedAttribute ea in tsk.ExtendedAttributes)
{
Console.WriteLine(ea.AttributeDefinition.Alias + “-” + ea.Value);
}
}

XML file is attached here for your kind reference. Please give it a try and let us know your feedback.