Page 1 of 1

how to remove some paragraphs?

PostPosted: Fri Aug 05, 2011 3:57 pm
by tosswang
hi,all:
now ,i meet a issue, there are some paragraph which are marked by specific signs in document .i need remove them.For example:

[AAA]
Qi Zhen the panda, 12, gave birth to her fourth set of twins at the Chengdu Research Base of Giant Panda Breeding on the morning of August 4, 2011. [Photo: Chengdu Panda Base]
Qi Zhen the panda, 12, gave birth to her fourth set of twins at the Chengdu Research Base of Giant Panda Breeding on the morning of August 4, 2011. [Photo: Chengdu Panda Base]
Qi Zhen the panda, 12, gave birth to her fourth set of twins at the Chengdu Research Base of Giant Panda Breeding on the morning of August 4, 2011. [Photo: Chengdu Panda Base]
[AAA]

i want to delete the content between the [AAA] tags,who can give me help ?

thanks in advance!

tosswang

Re: how to remove some paragraphs?

PostPosted: Sat Aug 06, 2011 1:14 am
by jason
Use XPath to find the paragraphs, and then delete them from the content list.

Easy provided the paragraphs aren't inside tables or text boxes etc. If they could be, you'll need extra logic.

Re: how to remove some paragraphs?

PostPosted: Tue Aug 09, 2011 2:04 pm
by tosswang
hi,jason:
thanks your reply.these paragraphs which i face are very long ,if i use XPath to find these paragraphs,java code will be long very much...Is there a better way to find these paragraphs in docx4j?

if i add some tags In these paragraphs beginning and end, can more easily find them? for example:

[[aaa]]
xxxxxxxxxxxxxxxxxxxxxxxxxx
[[aaa]]
[[bbb]]
xxxxxxxxxxxxxxxxxxxxxxxxxx
[[bbb]]
[[ccc]]
xxxxxxxxxxxxxxxxxxxxxxxxxx
[[ccc]]

thanks again

tosswang

Re: how to remove some paragraphs?

PostPosted: Fri Sep 02, 2011 6:38 pm
by tosswang
hi,jason:
if i want to remove content between tags [[aaa]],how do i create a xpath expression?can you provide some tip ?

thanks

tosswang