Problem with getting w:p for content control

Home Forums Open-Xml-PowerTools Problem with getting w:p for content control

This topic contains 1 reply, has 1 voice, and was last updated by  oritlevy24 2 months ago.

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

    oritlevy24
    Participant

    Hello,
    I’m a new open xml developer 🙂
    I looked at your “Advanced DocumentBuilder – import a document into a cell in a table, into a text box, or into a content control.” video and tried to implement it myself.

    I’ve called:
    XElement a = doc.MainDocumentPart.GetXDocument()
    .Root
    .Descendants(W.sdt)
    .Where(sdt => (string)sdt
    .Elements(W.sdtPr)
    .Elements(W.tag)
    .Attributes(W.val)
    .FirstOrDefault() == “333”)
    .FirstOrDefault()
    .Elements(W.sdtContent)
    .FirstOrDefault();

    and recieved this XML:

    <w:sdtContent xmlns:w=”http://schemas.openxmlformats.org/wordprocessingml/2006/main”>
    <w:tc>
    <w:tcPr>
    <w:tcW w:w=”6520″ w:type=”dxa” />
    </w:tcPr>
    <w:p w:rsidR=”00E95CF5″ w:rsidRPr=”000E324F” w:rsidRDefault=”000E324F” w:rsidP=”000E324F”>
    <w:pPr>
    <w:spacing w:after=”240″ w:line=”360″ w:lineRule=”auto” />
    <w:jc w:val=”both” />
    <w:rPr>
    <w:rStyle w:val=”PlaceholderText” />
    <w:sz w:val=”24″ />
    <w:rtl />
    </w:rPr>
    </w:pPr>
    <w:r>
    <w:rPr>
    <w:rStyle w:val=”PlaceholderText” />
    <w:sz w:val=”24″ />
    </w:rPr>
    <w:t>333</w:t>
    </w:r>
    </w:p>
    </w:tc>
    </w:sdtContent>

    when I call:
    XElement b = a.Elements(W.p).FirstOrDefault();
    I recieved null.

    Can you understand what is the problem?
    where can I put the docx for your inspection?
    Thanks,
    Orit

    #4119

    oritlevy24
    Participant

    Eric?

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

You must be logged in to reply to this topic.