You'll probably just have to remove them manually with a recursive function.
Here's some pseudocode:
removeLeafTextNodes(branch){
    removed = false
    for(child in branch){
        if(!removed && child instanceof Element){
            removed = true
            removeAllTextNodeChildren(element)
        }
        if(child instanceof Branch) removeLeafTextNodes(child)
    }
}

Naveen Murthy wrote:
>
> Hello,
>
> Recently I migrated an xml app that used JDOM to dom4j(1.6.1),
> and benefitted greatly by having a significantly lesser
> footprint and faster xpaths.
>
> But there is one difference im observing in the old JDOM vs DOM4j
>
> "When an element is having a child element + a textnode,
> im seeing that the old JDOM is totally ignoring the textnode.
> But dom4j is not doing the same."
>
> example:
> <test><abc></abc>naveen</test>
>
> when above string is Parsed into a DOM document --
> jdom neglects the textnode "naveen" all together. it only creates a 
> DOM for <test><abc></abc></test>
> where as- dom4j, keeps the textnode under the element 'test'
>
>
> Id assume that  DOM4j is doing the right thing by keeing the textnode,
> but is there any way to tell DOM4j to ignore such textnodes ( non leaf 
> textnodes )?
>
>
> Ps:
> :-) as a dev, i want to stick with the right thing; and try to prevent 
> "naveen' from being there in the first place ( which is appln bug)
> but the Mgmt guys, want only "xml layer" changed ( ie, jdom to dom4j ) 
> and rest LEFT ALONE..
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> dom4j-user mailing list
> dom4j-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to