Search code examples
c#openxmlpresentationml

Openxml 2.0 xml processing


I have a pretty basic question regarding the openxml sdk. I want to process pptx documents.

In my c# code from slideMaster1.xml I want to get a list of every XMLNode where the node's type is p:cNvPr because i want to store their values in a list of strings.

How can i do that?


Solution

  • Zoltan, The 'p:cNvPr' nodes are Non-Visual Drawing Properties which specifies non-visual canvas properties. See the MSDN documentation for more details.

    I wrote a small windows forms app that will open a power point and display the name attributes for all of the non-visual drawing properties for all of the layouts in the Master using the sdk. Please see screen shot below and link for zip of the Solution.

    enter image description here

    The code basically does the following:

    foreach (var slideMasterPart in PresentationPart.SlideMasterParts)
    {
        foreach (var layouts in slideMasterPart.SlideLayoutParts)
        {
        get each of the layouts.SlideLayout.CommonSlideData.ShapeTree.Descendants<NonVisualDrawingProperties>();
                    and put the name attribute to the grid.
        }
    }