ERROR in MergeField name in Word 2002 SP3 document

Hi

I have a document created with Word 2002 SP3.
This document have some MergeFields (FieldStart, RunNode, FieldSeparator, RunNode, FieldEnd).

I travel node by node and when i find a FieldStart node y catch the second RunNode.
This RunNode have the name of the MergeField.
But sometimes i have only ‘<<’, i don’t have ‘<>’.

if (curNode.getNodeType() == NodeType.FIELD_START)
{
    // RunNode FieldSeparator RunNode
    String nodeName = curNode.getNextSibling().getNextSibling().getNextSibling().getText();
}

The version of Aspose i’m using is Aspose.Words for Java 3.2.0

Thanks

Hi

Thanks for your inquiry. This occurs, because field value (displayed text) can consist of few Run nodes. You can inspect structure of Word document using DocumentExplorer (Aspose.Words demo application).
So, to get field value it is not enough to just get the text of the next Run after FieldSeparator node. You should get text of all Run nodes between FieldSeparator and FieldEnd nodes.
Please let me know if you need more assistance, I will be glad to help you.
Best regards,

To run DocumentExplorer, I have to install IntelliJ IDEA, and then import demo and compile it, or there is other way?

Hi

Thanks for your request. Please put the following jars in one directory:
Aspose.Words.DocumentExplorer.jar
itext-1.4.2.jar
testng-5.6-jdk15.jar
Aspose.Words.jdk15.jar
And use the following command to run DocumentExplorer:
java -classpath “Aspose.Words.DocumentExplorer.jar;Aspose.Words.jdk15.jar;itext-1.4.2.jar;testng-5.6-jdk15.jar” com.aspose.words.documentexplorer.MainForm
Hope this helps.
Best regards,