Yes Stanimir. I understood from a previous answer that:
<Root>
<FirstElement>Value</FirstElement>
</Root>
Can be interprated as:
<Root>\n<FirstElement>Value</FirstElement>\n<Root>
In that case, the "\n" character belongs to the <Root> element (I know
it takes times for me to understand that :o) ). That could explain the
#TEXT node with empty value.
I was looking the LSParser and LSParserFilter solution to get ride of
those empty nodes. Tried to implement one but not able to remove those
empty nodes.
Below my filter class:
public short acceptNode(Node node) {
// TODO Auto-generated method stub
Text text = (Text)node;
if (text.getTextContent().length() == 0) {
System.out.println("Rejected");
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
}
/* (non-Javadoc)
* @see org.w3c.dom.ls.LSParserFilter#getWhatToShow()
*/
public int getWhatToShow() {
// TODO Auto-generated method stub
return NodeFilter.SHOW_TEXT;
}
/* (non-Javadoc)
* @see org.w3c.dom.ls.LSParserFilter#startElement(org.w3c.dom.Element)
*/
public short startElement(Element element) {
// TODO Auto-generated method stub
System.out.println("Element parsed: " + element.getTagName());
return NodeFilter.FILTER_ACCEPT;
}
How can I specify that I do not want the #TEXT empty node be included in
my DOM tree?
Thx!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]