I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2005-09-16 21:03:50-07 by jmgdoc in response to 999
Re: insertParagraph -- path and position

If you want to insert a paragraph, you have to indicate an existing element, so the new paragraph is inserted before or after the given element.

An existing element can be selected by an XPath expression followed by a zero-based absolute position number. For example ("//text:p", 2) is the third paragraph and ("//text:h", 0) is the first header. So, if you want to insert a new paragraph before the 3rd existing paragraph, you can write
$doc->insertParagraph("//text:p", 2, position => 'before');
The 'position' option can be set to 'before' or 'after'; here, the new paragraph becomes the third one. With 'after' it would become the fourth.

Alternatively, if you previously got the third paragraph container, knowing that XPath query calculations are more time-consuming than direct element access, you should use it instead of the "path + absolute position", as below:
my $p = $doc->getParagraph(2); $doc->insertParagraph($p, position => 'before');
Direct Responses: Write a response