1

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 instanceof ListEntry))
                        outText = outText + "</ul>";

                }
                if (i == nParagrafi - 1) {
                    outText = outText + "</ul>";
                }
sra
  • 23,820
  • 7
  • 55
  • 89
Mahadevan
  • 11
  • 2

2 Answers2

2

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.
0

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

  • 1
    don't post just plain links, otherwise your answer is worthless if the link breaks! And exactly this this has happens in your case... – sra Jan 02 '12 at 08:49