I am now try to get the value of <wx:t wx:val="3."/>, is it possible to get it with POI API? <w:pPr> <w:pStyle w:val="ListParagraph"/> <w:listPr> <w:ilvl w:val="0"/> <w:ilfo w:val="3"/> <wx:t wx:val="3."/> <wx:font wx:val="Times New Roman"/> </w:listPr> <w:ind w:left="0" w:first-line="567"/> <w:jc w:val="left"/> <w:rPr> <w:rFonts w:ascii="仿宋_GB2312" w:fareast="仿宋_GB2312"/> <wx:font wx:val="仿宋_GB2312"/><w:color w:val="FF0000"/> </w:rPr> </w:pPr>
What did you try so far?
I want to deal document with content like that: 五、 Level 1 header 5.1 level 2 header 1. level 3 header Xml content read by XWPFDocument for them are: <w:pStyle w:val="ListParagraph"/> <w:numPr> <w:ilvl w:val="0"/> <w:numId w:val="2"/> </w:numPr> <w:pStyle w:val="ListParagraph"/> <w:numPr> <w:ilvl w:val="1"/> <w:numId w:val="2"/> </w:numPr> <w:pStyle w:val="1"/> <w:numPr> <w:ilvl w:val="0"/> <w:numId w:val="5"/> </w:numPr> While because the lack of namespace: xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint", the index in got lost. For example, there should be entry <wx:t wx:val="5.1"/> for level 2 header 5.1. Is there any way by which XWPFDocument can take wx into consideration? Still now, seems that I can only index the content by the relative position.
How are you trying to read it? How far do you get? What object are you expecting to find the <wx:t> object on? What do you see when you try to get it? Is it there if you dive down into the low level xmlbeans objects?
I want to get the val from <wx:t wx:val="1."/>, in this case I want to get "1.". 1. I debug class org.apache.poi.xwpf.usermodel.XWPFDocument.java, for code: // parse the document with cursor and add // the XmlObject to its lists XmlCursor cursor = ctDocument.getBody().newCursor(); cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); Found thatin XmlObject o, content in tag <wx:t> was not there. 2. The xml for the paragraph is as below, so I tried with p.getCTP().getPPr().getNumPr(), but only getIlvl() and getgetNumId() are provided for it. org.apache.poi.xwpf.usermodel.XWPFParagraph.getCTP().getPPr().getNumPr() will return node <w:listPr>, right? <w:p wsp:rsidR="003670EF" wsp:rsidRPr="007233F7" wsp:rsidRDefault="003670EF" wsp:rsidP="00FD47FD"> <w:pPr> <w:pStyle w:val="1"/> <w:listPr> <w:ilvl w:val="0"/> <w:ilfo w:val="5"/> <wx:t wx:val="1."/> <wx:font wx:val="Times New Roman"/> </w:listPr>