Convert XML to MPP using Python

XML is a widely used format for data exchange and storage while Microsoft Project is a popular project management tool. If you work with both of these technologies, you may be needing to convert XML data to Microsoft Project format in some scenarios. In this blog post, we will explore how to convert XML to MPP using Python.

XML to MPP Converter – Python API Configuration

Aspose.Tasks for Python via .NET API supports creating, editing, or manipulating Microsoft Project files. You can quickly configure the package or install it from PyPI by running the following pip installation command:

 pip install aspose-tasks

How to Convert XML to MPP using Python

Please follow the steps listed below for converting XML files to Microsoft Project file format:

  1. Get the source XML file.
  2. Load the Microsoft Project file.
  3. Copy the data and write the output to a Microsoft Project file.

Convert XML to MPP in Python

The following steps demonstrate how to convert XML to MPP using Python:

  1. Load the source XML file with the Project class.
  2. Access the MPP file and copy the data from the XML file.
  3. Export the MPP file while specifying a value from the SaveFileFormat enumeration.

Once the Python package is configured, we can begin writing our Python script. Here is a sample Python script that does the conversion of XML to MPP format:

import aspose.tasks as tasks

# Load input XML file
xmlProject = tasks.Project("file.xml")

# Load input Project file
mppProject = tasks.Project("Input.mpp")

# Call the copy method
xmlProject.copy_to(mppProject)

# Save output MPP file
mppProject.save("XMLtoMPP.mpp", tasks.saving.SaveFileFormat.MPP);

Get a Free API License

You can request a free temporary license to evaluate the API to its full capacity.

Conclusion

In conclusion, you have learned how to convert an XML file to MPP Microsoft Project file format using Python. It is a quick yet powerful and flexible way to convert XML data to MPP format. Moreover, you may take a look at different chapters in the documentation section to explore more features. In case of any ambiguities, please feel free to reach out to us at the free support forum.

See Also