How do I implement cross-referencing of custom heading styles in code?

@lovecomputer Hierarchy is right, but it is expected that it does not match visual representation of the document in MS Word due to using floating objects. PreviousSibling and NextSibling returns neighbor nodes according to the document object model, that matches the original document internal structure. Unfortunately, there is no way to return nodes in visual order.

How do I create a new list style and link the level of the list to the style?
1 The first step is to define a new list style
2 Step 2, in the new list style, select Format - Set Numbering
3 In the third step, select Level 1, select Link Level to Style, and select “Title 1”, 4 Here’s my final new list style and linking levels to style(“Title 1”, “Title 2”, “Title 3”)

@lovecomputer You can use the following cod to achieve this:

Document doc = new Document();

// Create a list.
Aspose.Words.Lists.List lst = doc.Lists.Add(ListTemplate.OutlineLegal);

// Get heading styles and specify list and level.
Style h1 = doc.Styles[StyleIdentifier.Heading1];
h1.ListFormat.List = lst;
h1.ListFormat.ListLevelNumber = 0;
Style h2 = doc.Styles[StyleIdentifier.Heading2];
h2.ListFormat.List = lst;
h2.ListFormat.ListLevelNumber = 1;
Style h3 = doc.Styles[StyleIdentifier.Heading3];
h3.ListFormat.List = lst;
h3.ListFormat.ListLevelNumber = 2;

// Test our chnages.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Writeln("Heading 1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
builder.Writeln("Some text");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Writeln("Heading 1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
builder.Writeln("Some text");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 2");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
builder.Writeln("Some text");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;
builder.Writeln("Heading 3");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
builder.Writeln("Some text");

doc.Save(@"C:\Temp\out.docx");