Can i get the text of a ListItem?


Can i get the content of the listItem? like I want the text '第4章"
but when i use code like :

NodeCollection<Paragraph> childNodes = doc.getChildNodes(NodeType.PARAGRAPH, true);

for (Paragraph paragraph :  childNodes) {
    if (paragraph.isListItem()){
        System.out.println("=========");
        System.out.println(paragraph.getListLabel().getLabelString());
    }
}

it printed nothing.
here is the test file.
test.docx (109.9 KB)
how can i get the content of it ?

ahhhhh i knew it !!! before using it. use Document.updateListLabels();

@Madecho Yes, you are absolutely right. before using Paragraph.ListLabel property it is required to call Document.updateListLabels method. It is perfect that you managed to resolve the problem. Please feel free to ask in case of any issues, we will be glad to help you.

1 Like