Hi Team,
I have been using Aspose.words for parsing a token from .DOC word file.
Now I want to parse the same for .DOCX file
I assumed that my code should work for .DOCX file as well (correct me if I'm wrong here)
case1: .DOC file with content "{!name#value}"
case2: .DOCX file with content "{!name#value}"
// where {!name#value} is my token format which means give value of name object
This is my code which tries to parse the token string and replace with desired value:
----------------------------
// rawData of either .DOC or .DOCX file
public static void somefn(){
com.aspose.wordsDocument doc = new Document(new ByteArrayInputStream(rawData));
scanNode(doc);
}
public static void scanNode(Node node){
if (node instanceof Run) {
Run run = (Run)node;
String template = run.getText();
sysout(template);
// do something with tokem
}
if (!(node instanceof CompositeNode))
return;
CompositeNode cnode = (CompositeNode)node;
Node node2 = cnode.getFirstChild();
while (node2 != null) {
scanNode(node2, parser);
node2 = node2.getNextSibling();
}
}
Observations:
1) .DOC file prints
{!name#text}
2) .DOCX file prints
{!
name
#text
}
---------------------------------
The output is different for case1 and case2
I need the .DOCX to work same as .DOC
Am I missing something? Should the .DOCX file be parsed differently?
Thanks in advance,
Tvk Reddy