none
Urgently looking for code sample to replace content of <w:t> with value from <w:dataBinding> RRS feed

  • Question

  • Hi,

     

    Anyone got code samples (maybe using OOXML SDK and Linq to XML) on how to take the CustomXML data based on the <w: dataBinding> xpath and replace it on the subsequent <w:t> element? My sample XML is as below.

     

    Code Snippet
      <w:sdtPr>
                <w:dataBinding w:prefixMappings="xmlns:ns0='http://test'" w:xpath="/ns0:root[1]/ns0:name[1]" w:storeItemID="{3880a46f-ed4d-4436-8d4a-89276c247d25}" />
                <w:alias w:val="name" />
                <w:tag w:val="name" />
                <w:id w:val="14578684" />
                <w:placeholder>
                  <w:docPart w:val="DefaultPlaceholder_22675703" />
                </w:placeholder>
                <w:showingPlcHdr />
                <w:text />
              </w:sdtPr>
              <w:sdtContent>
                <w:tc>
                  <w:tcPr>
                    <w:tcW w:w="7758" w:type="dxa" />
                  </w:tcPr>
                  <w:p w:rsidR="00D657D6" w:rsidRDefault="00D657D6">
                    <w:r w:rsidRPr="00E749B3">
                      <w:rPr>
                        <w:rStyle w:val="PlaceholderText" />
                      </w:rPr>
                      <w:t>Click here to enter text.</w:t>
                    </w:r>
                  </w:p>
                </w:tc>
              </w:sdtContent>
            </w:sdt>

     

     

    I need to do so because my investigation found out that MS Office Compatibility Pack for Office 2007 Formats renders the value in <w:t> tag and not the value of the CustomXML part, which is totally different from how Officer 2007 renders the document.

    Monday, May 26, 2008 10:06 PM

Answers