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

Free Support Forum - aspose.com

Level difference with two Combo Boxes


I have two Word documents, both containing only a combo box. The problem I get is the difference between levels of these combo boxes.

Here’s the code I used:

String path1 = "combobox1.docx";
String path2 = "combobox2.docx";

Document document1 = new Document(path1);
Document document2 = new Document(path2);
NodeCollection sdts1 = document1.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true);
NodeCollection sdts2 = document2.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true);
StructuredDocumentTag comboBox1 = (StructuredDocumentTag) sdts1.get(0);
StructuredDocumentTag comboBox2 = (StructuredDocumentTag) sdts2.get(0);
System.out.println("ComboBox1 level: " + comboBox1.getLevel());
System.out.println("ComboBox2 level: " + comboBox2.getLevel());

And this is the result:
ComboBox1 level: 2
ComboBox2 level: 1

Can you check this?


Hi Zeljko,

Thanks for your inquiry. The MarkupLevel of StructuredDocumentTag is correct for both documents. Please check the both documents in DOM. You may also check this in document.xml of input documents. See the attached images for detail. Please read following documentation link for your kind reference.

Please check following code example and let us know if you have any more queries.

String path1 = MyDir + "combobox1.docx";
String path2 = MyDir + "combobox2.docx";
Document document1 = new Document(path1);
Document document2 = new Document(path2);
System.out.println(document1.getFirstSection().getBody().getFirstChild().getNodeType() == NodeType.STRUCTURED_DOCUMENT_TAG);
System.out.println(document2.getFirstSection().getBody().getFirstChild().getNodeType() == NodeType.PARAGRAPH);