No contents to be retrieved from Notebook object created from .onetoc2

Below are the sample codes I got from Aspose .Note developer’s guide document. Even though I can load the file, I cannot get any contents inside that index file. Debug found out notebook.getDisplayName is null, notebook.getcount is 0, and get children nodes are also zero. Is there anything else I should do to get the contents of the onenote index file?

Thanks.
Biyan

String inputFile = “Open Notebook.onetoc2”;
Path inputPath = Utils.getPath(LoadingNotebook.class, inputFile);

Notebook notebook = new Notebook(inputPath.toString());

for (INotebookChildNode notebookChildNode : notebook) {
System.out.println(notebookChildNode.getDisplayName());

if (notebookChildNode instanceof Document) {
	// Do something with child document
} else if (notebookChildNode instanceof Notebook) {
	// Do something with child notebook
}

}

In other words, is there any other way for me to retrieve the children document or .one files indexed in this .onetoc2 file?

@blikbsi,

Thank you for writing to Aspose support team.

You may please try following sample code using attached sample file and share the feedback. Please use latest version Aspose.Note for Java 17.8.0 in your testing.

Notebook notebook = new Notebook("Open Notebook.onetoc2");
for(INotebookChildNode notebookChildNode : notebook)
//for (INotebookChildNode notebookChildNode : notebook)
{
    System.out.println(notebookChildNode.getDisplayName());

    if (notebookChildNode instanceof Document)
    {
        // Do something with child document
        System.out.println(notebookChildNode.getDisplayName());
    }
        else if (notebookChildNode instanceof Notebook)
    {
        // Do something with child notebook
        System.out.println(notebookChildNode.getDisplayName());
    }
}

sample.zip (10.5 KB)

That works now. Thanks for pointing out the solution.

Biyan

@blikbsi,

Thank you for the feedback.