DocumentBuilder "Sequence contains no elements error"

Home Forums Open-Xml-PowerTools DocumentBuilder "Sequence contains no elements error"

This topic contains 1 reply, has 2 voices, and was last updated by  Eric White 7 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3857

    pravi
    Participant

    Hi Eric and all,
    I am using DocumentBuilder to append an document(docx) to another including header, footers and content. When I try to do so, I get this – Sequence contains no element error..

    There is something strange here, in that if I reverse the order of the appending, It works fine and the resulting docx, retains the header and footer info of both the docs respectively.

    If I open the first docx (that I am trying to append to and is the problem) using MS word, do nothing more than, add a space in the body, save it and try appending to it, it works fine. But this sort of user interaction is not possible.

    Debugging through the BuildDocument function of the DocumentBuilder, I can see where the problem is, but I am struggling to tie it back to the word docx that I trying to append to.

    I have to admit that If I try to validate the docx using productivity tool, there are at least 49 errors and again, struggling to tie it back to the actual document and its content..

    Is there any solution or suggestions to resolving this? Any help is much appreciated..

    Thank you
    Pravi.

    #3877

    Eric White
    Keymaster

    Hi Pravi,

    When you say:

    >> I have to admit that If I try to validate the docx using productivity tool, there are at least 49 errors and again, struggling to tie it back to the actual document and its content..

    Are you referring to the input document? One constraint about DocumentBuilder is that it is not prepared to process documents that have errors (with a few common exceptions that Word processes properly, and generates sometimes).

    In general, spend some effort in making sure that your input documents are perfect – this is my advice.

    Best, Eric

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.