Get a node's inner XML as String in Java DOM

Clash Royale CLAN TAG #URR8PPP Get a node's inner XML as String in Java DOM I have an XML org.w3c.dom.Node that looks like this: <variable name="variableName"> <br /><strong>foo</strong> bar </variable> How do I get the <br /><strong>foo</strong> bar part as a String? <br /><strong>foo</strong> bar 8 Answers 8 There is no simple method on org.w3c.dom.Node for this. getTextContent() gives the text of each child node concatenated together. getNodeValue() will give you the text of the current node if it is an Attribute , CDATA or Text node. So you would need to serialize the node using a combination of getChildNodes() , getNodeName() and getNodeValue() to build the string. org.w3c.dom.Node getTextContent() getNodeValue() Attribute CDATA Text getChildNodes() getNodeName() getNodeValue() You can also do it with on...