XMLNodes in Headers & Footers

  • Thread starter Jonathan Greensted [MVP]
  • Start date
J

Jonathan Greensted [MVP]

Hi

I’m struggling to find the best way to update XMLNodes contained within a
Word document header (or footer).

I would have expected "document.SelectNodes(...)" to include nodes from the
headers and footers but it doesnt.

The only answer(ish) I've found is:

foreach (Section sect in _doc.Sections)
{
foreach (HeaderFooter headfoot in sect.Headers)
{
if (headfoot.Range.XMLNodes.Count>0)
{
// headfoot.Range.XMLNodes.SelectNodes(...)
}
}

foreach (HeaderFooter headfoot in sect.Footers)
{
if (headfoot.Range.XMLNodes.Count>0)
{
// headfoot.Range.XMLNodes.SelectNodes(...)
}
}
}

But (a) this seems a bit pants and (b) it doesnt seem to work anyway!

Does anyone know how to do this the "official" way?

Many thanks

Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top