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

Free Support Forum - aspose.com

How to get sequence text

Hi there

i found examples on how to get the sequence numbers using
Field.Result

How do i get the text portion of the sequence?
for example, how do i get the Blah portion below?

  1. Blah Blah
  2. Blah Blah

thanks.

@gavinduffy,

Please try using the following code:

foreach(Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
    if (para.IsListItem)
    {
        Console.WriteLine(para.ToString(SaveFormat.Text));
    }
} 

In case the problem still remains, please ZIP and upload your input Word document and a screenshot (highlighting the portion of text that you want to get) here for testing. We will then investigate the issue on our end and provide you more information.

did not work.
does not recognize the para’s as listitems.
test.zip (6.7 KB)
i have attached a zipped copy of the document.
i am dealing with 1500 similar docs.
thanks

@gavinduffy,

Please try using the following code:

Document doc = new Document("E:\\temp\\test.doc");

foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
    if (para.FirstChild.NodeType == NodeType.FieldStart)
    {
        Field field = para.Range.Fields[0];
        if (field.Type == FieldType.FieldSequence)
        {
            field.Remove();

            Run run = para.Runs[0];
            run.Text = run.Text.Replace(".", "");
            run.Text = run.Text.Replace(ControlChar.Tab, "");

            Console.WriteLine(para.ToString(SaveFormat.Text));
            Console.WriteLine("=============================");
        }                    
    }
}

thank you, I can make that work.