?
Solved

How to find sections in Word document Using Open XML

Posted on 2014-10-09
1
Medium Priority
?
219 Views
Last Modified: 2014-10-14
Hi Team,

Can u plz provide code to find sections  in word document using open XML
0
Comment
Question by:mannevenu26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
Prashant Jagdale earned 1500 total points
ID: 40372368
Try using code below:
 static void FindSections(string filename)
        {
            using (WordprocessingDocument wpDoc = WordprocessingDocument.Open(filename, true))
            {
                MainDocumentPart mpDoc = wpDoc.MainDocumentPart;
                List<ParagraphProperties> pProps = mpDoc.Document.Descendants<ParagraphProperties>()
                .Where(pPr => IsContainsSection(pPr)).ToList();
                foreach (ParagraphProperties pPr in pProps)
                {
                    SectionProperties pSP= pPr.GetFirstChild<SectionProperties>();
                }
                
            }
        }
        static bool IsContainsSection(ParagraphProperties pPr)
        {
            SectionProperties sectPr = pPr.GetFirstChild<SectionProperties>();
            if (sectPr == null)
                return false;
            else
                return true;
        }

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question