Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9002289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:33:03+00:00 2026-06-16T00:33:03+00:00

This is not really a question since I already have found the reason for

  • 0

This is not really a question since I already have found the reason for this problemRetrieving descendants from OpenXml body

The descendants are retrieved using this code.

using System.IO;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace Testolini
{
    class Program
    {
        static void Main(string[] args)
        {
            var filename = Path.GetTempFileName();
            var word = WordprocessingDocument.Create(filename, DocumentFormat.OpenXml.WordprocessingDocumentType.Document);
            word.AddMainDocumentPart();
            word.MainDocumentPart.Document = new Document(
                                                new Body(
                                                    new Paragraph(
                                                        new Run(
                                                            new Paragraph(
                                                                new Run(
                                                                    new Text("test1"))),
                                                            new Paragraph(
                                                                new Run(
                                                                    new Text("test2"))),
                                                            new Paragraph(
                                                                new Run(
                                                                    new Text("test3")))))));
            word.Close();

            using (var memorystream = new MemoryStream(File.ReadAllBytes(filename)))
            {
                var word2 = WordprocessingDocument.Open(memorystream, true);

                var descendants = word2.MainDocumentPart.Document.Body.Descendants();

                word.Close();

            }
        }
    }
}

If you get the same problem. It can be because the XML fil does not validate with the ECMA standard.
In my case the problem was that i had nested paragraphs.

The problem shows up when I opened the document using bytearray and memorystream. It looks like the elements is validated and if the validation fails it becames an OpenXmlUnknownElement.

If anyone have better explanation and maybe a more precise reason for this problem I would love to learn more about it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:33:04+00:00Added an answer on June 16, 2026 at 12:33 am

    A Run cannot contain another Paragraph.

    Here is a list of valid child elements for a Run:

    annotationRef (Comment Information Block)
    br (Break)
    commentReference (Comment Content Reference Mark)
    contentPart (Content Part)
    continuationSeparator (Continuation Separator Mark)
    cr (Carriage Return)
    dayLong (Date Block – Long Day Format)
    dayShort (Date Block – Short Day Format)
    delInstrText (Deleted Field Code)
    delText (Deleted Text)
    drawing (DrawingML Object)
    endnoteRef (Endnote Reference Mark)
    endnoteReference (Endnote Reference)
    fldChar (Complex Field Character)
    footnoteRef (Footnote Reference Mark)
    footnoteReference (Footnote Reference)
    instrText (Field Code)
    lastRenderedPageBreak (Position of Last Calculated Page Break)
    monthLong (Date Block – Long Month Format)
    monthShort (Date Block – Short Month Format)
    noBreakHyphen (Non Breaking Hyphen Character)
    object (Embedded Object)
    pgNum (Page Number Block)
    ptab (Absolute Position Tab Character)
    rPr (Run Properties)
    ruby (Phonetic Guide)
    separator (Footnote/Endnote Separator Mark)
    softHyphen (Optional Hyphen Character)
    sym (Symbol Character)
    t (Text)
    tab (Tab Character)
    yearLong (Date Block – Long Year Format)
    yearShort (Date Block – Short Year Format)

    Taken from MSDN.

    Why do you need “nested” paragraphs?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is not really a question because I just solved the problem, but I
This is not really a programming question, more of an algorithmic one. The problem:
I've already posted this question here , but since it's maybe not that Qt-specific,
This is not really a programming question but please bear with me as I
This is not a really Programming Question, but please bear with me as it's
I know this question is not really important.. however I've been wondering: Which of
Not really too sure how to word this question, therefore if you don't particularly
I'm not really sure how to ask this question, but I'll do my best.
I am not really sure how to word this question, so I did the
This is a really short question I think but I'm not sure I understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.