[jdom-interest] Reinitialisation

Per Norrman per.norrman at austers.se
Fri Aug 20 07:39:53 PDT 2004


Gareth Hughes wrote:

> I'm building a JDOM Doc and eventually attaching the resulting XML doc to a
> SAAJ SOAPMessage. I'm using the SOAPMessage.writeTo method to output the
> message to a file for visual verification. The attached XML contains a blank
> line where I removed the element in question (using
> Parent.removeContent(element)).
> 
> This is causing problems with my SOAP req. I hoping there is some way I can
> reinitialise the JDOM doc before attachment to the SOAPMessage.
> 
> Any help is much appreciated. 
>

Help is on the way:

    /*
     * Remove an element and any immediatley preceding whitespace
     */
    Element e = ....
    List content = e.getParent().getContent();
    int index = content.indexOf(e);
    content.remove(index);
    if (index > 0
         && content.get(index - 1) instanceof Text
         && ((Text) content.get(index - 1)).getTextTrim().length() == 0) {
       content.remove(index - 1);
    }

/pmn




More information about the jdom-interest mailing list