[EMAIL PROTECTED] wrote:

Hi!

I try to remove all <DIV>s from a Document but this seems to be somewhat tricky :-) I'd prefer to use a Visitor; the code below throws an NullPointerException. The second approach simply doesn't work:


You could do it with a simple XSL transformation from a DocumentSource to a DocumentResult (get the Document back from this):

  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>


<xsl:template match="DIV|div"> <xsl:apply-templates/> </xsl:template>

  or

  <xsl:template match="DIV|div">
    <xsl:element name="[EMAIL PROTECTED]">
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

best,
-Rob



-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to