Why paragraph.ListLabel.LabelString is "%1"; or "%1.%2"

I have text is :
1 test title 1(1 is number list)
2 test title 2(2 is numbe list)
2.1 test title 2.1(2.1 is number list)
I use this code to get 1 or get 2 or get 2.1,but not Success

doca.UpdateListLabels();
Aspose.Words.Paragraph p0;
foreach (Aspose.Words.Paragraph paragraph in doca.Sections[0].Body.Paragraphs)
{
    if (paragraph.ListFormat.IsListItem)
    {
        string label = paragraph.ListLabel.LabelString;
    }
}

Hi,

Thanks for your inquiry. Please use the ListLevel.NumberFormat for your requirement. Among normal text characters, the string can contain placeholder characters \x0000 to \x0008 representing the numbers from the corresponding list levels.

For example, the string “\x0000.\x0001)” will generate a list label that looks something like “1.5)”. The number “1” is the current number from the 1st list level, the number “5” is the current number from the 2nd list level. Null is not allowed, but an empty string meaning no number is valid.

I suggest your to read following documentation links for your kind reference.
https://reference.aspose.com/words/net/aspose.words.lists/list/
https://reference.aspose.com/words/net/aspose.words.lists/listlabel/
https://reference.aspose.com/words/net/aspose.words.lists/listlevel/

Please use the following code snippet for your requirements.

//Create document
Document doc = new Document();
// Create Builder
DocumentBuilder builder = new DocumentBuilder(doc);
// Start list
builder.ListFormat.ApplyNumberDefault();
// Set number format
builder.ListFormat.ListLevel.NumberFormat = "\u0000";
builder.Writeln("Item 1");
builder.Writeln("Item 2");
// Increases the list level of the current paragraph by one level.
builder.ListFormat.ListIndent();
builder.ListFormat.ListLevel.NumberFormat = "\u0000.\u0001";
builder.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
builder.Writeln("Item 2.1");
builder.Writeln("Item 2.2");
builder.ListFormat.ListIndent();
builder.ListFormat.ListLevel.NumberFormat = "\u0000.\u0001.\u0002";
builder.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
builder.Writeln("Item 2.2.1");
builder.Writeln("Item 2.2.2");
// Decreases the list level of the current paragraph by one level.
builder.ListFormat.ListOutdent();
builder.Writeln("Item 2.3");
builder.ListFormat.ListOutdent();
builder.Writeln("Item 3");
builder.ListFormat.RemoveNumbers();
doc.Save(MyDir + "AsposeOut.docx");

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a numbered list based on one of the Microsoft Word list templates and
// apply it to the current paragraph in the document builder.
builder.ListFormat.List = doc.Lists.Add(ListTemplate.NumberArabicDot);
builder.ListFormat.List.ListLevels[0].NumberFormat = "\x0000";
builder.ListFormat.List.ListLevels[1].NumberFormat = "\x0000.\x0000";
// There are 9 levels in this list, lets try them all.
for (int i = 0; i < 9; i++)
{
    builder.ListFormat.ListLevelNumber = i;
    builder.Writeln("Level " + i);
}
// Create a bulleted list based on one of the Microsoft Word list templates
// and apply it to the current paragraph in the document builder.
builder.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDiamonds);
// There are 9 levels in this list, lets try them all.
for (int i = 0; i < 9; i++)
{
    builder.ListFormat.ListLevelNumber = i;
    builder.Writeln("Level " + i);
}
// This is a way to stop list formatting. 
builder.ListFormat.List = null;
builder.Document.Save(MyDir + "Lists.SpecifyListLevel Out.doc");

thanks,that is good

Hi,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.