Free Support Forum - aspose.com

How to remove element from ordered list

Hi,


I need to look through ordered list and to remove some elements. Every element in list is presented as a simple paragraph, but how is it possible to distinguish these paragraphs (elements) from those that are not related to any list?

Thanks





Hi Vasily,


Thanks for your inquiry.

You can check for the ListFormat.IsListItem property; it returns true when the paragraph has bulleted or numbered formatting applied to it. For example, the following code finds and outputs all paragraphs in a document that are bulleted or numbered.

NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph para in paras)

{

if (para.ListFormat.IsListItem)

{

Console.WriteLine(string.Format("*** A paragraph belongs to list {0}", para.ListFormat.List.ListId));

Console.WriteLine(para.GetText());

}

}


I hope, this helps.

Best regards,