Section- Section Groups- Notebooks...Object Type

Hi,

I’m parsing OneNote notebook - trying to make proper hierarchical folder structure from it.

I noticed that NodeType “Section” is never used because all Sections and Section Groups appear to have “Document” node type.
foreach (var child in notebook.GetChildNodes())
{
switch (child.NodeType)
{
case NodeType.Document: //section or groupsection
              <span style="color:#569cd6;">break</span>;</pre>Code above get's 4 times in "Document" case, and onetoc2 file have Section, SectionGroup, Empty Section without page. last part is a OneNote Rubbish Bin - which I understand is an artificial section with erased objects which is fine.</div><div><br></div><div>Second issue is with real type shown in debug mode... Section is a "document type" and section group is a "notebook" type. </div><div><br></div><div>[ please see attached file ] </div><div><br></div><div>How can I tell the difference between Section, Section Group and Notebook  from code when parsing structure ?<br><br>I've also attached 7zipped notebook for test example.</div><div><br></div><div>Thanks in advance.</div>

Hi Actur,

Thank you for writing to Aspose support team.
Each section in one note file is treated as a document, whereas group is treated as a notebook. You may please give a try to the following sample code which differentiates the sections and notebooks (group). Please give it a try and share the feedback and visit here for more information about working with notebooks.

var notebook = new Notebook(@"Notebook.onetoc2");
foreach (var notebookChildNode in notebook)
{

Console.WriteLine(notebookChildNode.DisplayName);
if (notebookChildNode is Document)
{

Console.WriteLine("Its section");
// Do something with child document

}

else if (notebookChildNode is Notebook)
{

Console.WriteLine("Its notebook");
// Do something with child notebook

}

}

Thanks, that do the trick.

You are welcome.