none
How do I get all top level paragraphs? RRS feed

Answers

  • Hi DavidThi808,

    Thanks for your question.

    I think you could try this to get all paragraphs under body but not tablecell or textbox:

    var

     

     

    paragraphs = body.Elements<Paragraph>();

    Hope this will help you. If you have any questions, please let me know.

    Thanks,

    Lu
    • Marked as answer by DavidThi808 Sunday, January 17, 2010 8:30 AM
    Friday, January 15, 2010 1:28 AM

All replies

  • Hi, David

    What do you mean by the ones that are not inside another object? In my opinion, paragraphs have to be placed under their allowed parents such as body, table cell. Could you please give more specific info so that we can indentify the problem?

    Thanks,
    Ethan
    Thursday, January 14, 2010 7:47 AM
    Moderator
  • Hi;

    Yes, those under body, but not elsewhere. So I want document/body/p but not document/body/table/row/cell/p or document/body/textbox/p.

    thanks - dave
    Windward Reports - World's Greatest SharePoint Reporting & DocGen
    Thursday, January 14, 2010 6:41 PM
  • Hi DavidThi808,

    Thanks for your question.

    I think you could try this to get all paragraphs under body but not tablecell or textbox:

    var

     

     

    paragraphs = body.Elements<Paragraph>();

    Hope this will help you. If you have any questions, please let me know.

    Thanks,

    Lu
    • Marked as answer by DavidThi808 Sunday, January 17, 2010 8:30 AM
    Friday, January 15, 2010 1:28 AM
  • Ok, that was too easy - thank you.

    BTW, the Descendents() and the Elements<Paragraph> - is that Open XML, LINQ, or both? I just ordered a coupld of books on LINQ to learn it.

    thanks - dave
    Windward Reports - World's Greatest SharePoint Reporting & DocGen
    Sunday, January 17, 2010 8:32 AM
  • Hi DavidThi808,

    The Descendents() and the Elements<Paragraph> are both Open XML. There are some similar methods like System.Xml.Linq.XElement.DescendantNodesAndSelf() and System.Xml.Linq.XElement.DescendantsAndSelf(System.Xml.Linq.XName) in LINQ but they do not support strong type in Open XML format.

    If you have any questions, please let me know.

    Thanks,

    Lu
    Monday, January 18, 2010 8:57 AM
  • That is very well thought out on the part of the Open XML group.

    thanks - dave
    Windward Reports - World's Greatest SharePoint Reporting & DocGen
    Monday, January 18, 2010 4:20 PM