Possible Duplicate:
How to I output org.w3c.dom.Element to string format in java?
I have an xml snippet, like
<div>
<span>
<a href="http://someUrl.com">Cool site, bro!</a>
</span>
</div>
And an org.w3c.dom.Node, corresponding to my div element. How do I get a Node's String representation, that contains raw markup? I.e. I want to get
Node node = (Node) myXpathExpression.evaluate(document, XPathConstants.NODE);
String rawMarkup = getRawMarkup(node);
assertEquals("\n\t\t<span>\n\t\t\t<a href=\"http://someUrl.com\">Cool site, bro!</a>\n\t\t</span>\n\t", rawMarkup)
Also, what is the best strategy if I want to filter out some tags (e.g. , etc.) and get raw markup without them?