I used the following code to read list structures from a word file using hwpf. My question is how to read a list structure that is nested ie a list within a list within a list and so on.
if (p instanceof ListEntry) {
ListEntry entry = (ListEntry) p;
outText = entry.text();
outText = "<li>" + outText + "</li>";
// verifca prima e ultimo
if (i > 1) {
pPrev = range.getParagraph(i - 1);
if (!(pPrev instanceof ListEntry))
outText = "<ul>" + outText;
}
if (i < nParagrafi - 1) {
pNext = range.getParagraph(i + 1);
if (!(pNext ins开发者_开发百科tanceof ListEntry))
outText = outText + "</ul>";
}
if (i == nParagrafi - 1) {
outText = outText + "</ul>";
}
Like Brandon said, it is a list with different List Levels.
entry = (ListEntry)p;
entry.getIlvl();
//This method returns an integer: 0 being a flat list, 1 being a nested list.
You thinking about it all wrong. It's not really a list nested within a list. It's a list with different list levels.
http://www.brandonrachal.com/?p=117
精彩评论