Search code examples
mpxj

Is there any way to remove or not to include certain xml elements while creating from mpxj library?


currently when working with mpxj library, generated task xml will have following attributes

<Task>
    <UID>0</UID>
    <ID>0</ID>
    <Name>Naruto Uzumaki</Name>
    <Active>1</Active>
    <Manual>0</Manual>
      ......
      ......
</Task>

I do not want Active and Manual tags present in the generated xml, is there any way to achieve this? Kindly help.

Thanks in Advance.


Solution

  • I'm not sure of MS Project's behaviour if these values are removed entirely... if it would give you the defaults you are expecting when it reads the file. On that basis it is not something you can change in MPXJ itself.

    However, one simple way to achieve what you want would be to apply an XSL transformation to the generated XML to remove the elements you don't want. The answer to this StackOverflow question provides an example of how this could be done.

    Assuming you are using Java and you are writing to a stream you can probably use one of the mechanisms highlighted in this StackOverflow question to take the output directly from MPXJ and pass it through an XSL transformation.