Iterating through XML tags in word is slow.

V

Velavan

Hi,
I have a word template with approx 550 checkbox form fields and some textbox
form fields. I need to save this as XML data. Since word does not store the
checkbox values in the XML data while doing a save as XML data, I am trying
to iterate through the XML tags and create the XML data myself. This is slow
(takes about 2 mins). I am including the code below.

UnProtectDocument();
object o = 1;
foreach(XMLNode myXmlNode in m_Document.XMLNodes)
{
if(!myXmlNode.HasChildNodes)
{
Range range = myXmlNode.Range;
FormField formField = range.FormFields.get_Item(ref o);
if (formField.Type == WdFieldType.wdFieldFormCheckBox)
{
if (formField.CheckBox.Value == true)
{
Trace.WriteLine(formField.Name + " value = Checked");
}
}
}
}
ProtectDocument();

Thanks.
 

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