We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Document.SelectNodes(@"//FieldStart") finding huge number of nodes in particular document

Calling SelectNodes on the attached document returns ~6200 FieldStart nodes. This is causing a knock-on slowdown in our software as a later processing loop runs that many times.

Our client tells us this document has been “macro-enabled” by a company called Softeryx. I’m not entirely sure what that means but I can’t see anything particularly unusual in the file at first glance.

Can you provide any guidance as to what the issue is here and how I might work around it to avoid this slowdown?

document.zip (80.7 KB)

@TristanP

Thanks for your inquiry. A field in a Word document is a complex structure consisting of multiple nodes that include field start, field code, field separator, field result and field end.

You are facing the expected behavior of Aspose.Words. You can press Alt+F9 in Microsoft Word to to check all nested fields in the document. Your document contains 6621 fields. You can test it by using following code snippet.

var document = new Document(MyDir + "document.docx");
Console.WriteLine(document.Range.Fields.Count);
Console.WriteLine(document.GetChildNodes(NodeType.FieldStart, true).Count);
NodeList nodeList = document.SelectNodes(@"//FieldStart");
Console.WriteLine(nodeList.Count);

Ah I see, yes that expands to 66 pages of junk ‘IF’ statements, no wonder it was taking so long to process.

As always, your support is quick and astute, thanks again!