wordml - How to get FootnoteRefrence Id in OpenXML using C# -


i'm having ooxml document's paragraph element this. want footnoterefrence id text programmatically using c#.

text document.xml

<w:p>   <w:r>     <w:rpr>       <w:rstyle w:val="footnotereference" />     </w:rpr>     <w:footnotereference w:id="2" />   </w:r> </w:p> 

c# code

private bodypara writepara(bodypara bpara2, openxmlelement ptag)     {         footnotes fn = null;         foreach (var run in ptag.descendants<run>())         {             if (run.haschildren)             {                  foreach (var runprop in run.descendants<runproperties>())                 {                     foreach (var runstyle in runprop.descendants<runstyle>())                     {                          if (runstyle.val != null)                         {                             string runsty = runstyle.val.value;                             if (runsty == "footnotereference")                             {                                 if (fn != null)                                 {                                     bpara2.footnotes.add(fn);                                  }                                 fn = new footnotes();                              }                             else if (runsty == "commentreference")                             {                               }                             else                             {                                 if (fn != null)                                 {                                     fn.foottext = fn.foottext + run.innertext;                                 }                             }                          }                     }                     //footnotespart footnotespart = worddoc.maindocumentpart.footnotespart;                     //if (footnotespart != null)                     //{                     //  ienumerable<footnote> footnotes = footnotespart.footnotes.elements<footnote>();                     // ...                     //}                     if (runprop.nextsibling() != null)                     {                         openxmlelement fr = runprop.nextsibling();                         foreach (var fnref in fr)                         {                             if (fnref != null)                             {                                 // fn.footnoteid = fnref.id.value.tostring();                             }                         }                     }                     foreach (var shd in runprop.descendants<shading>())                     {                         if (shd.fill != null)                         {                             string shdvalue = shd.fill.value;                         }                     }                 }             }         }          return bpara2;     } 

i'm using footnote reference id of each footnote. in loop cant descendants of run of type footnotereference , value. pls me this. thank you.

sorry did mistake in parameters, instead of using paragraph ptag in parameter list, used openxmlelement ptag. changed generic specific. works now.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -