To text

<root>
  <elem id="yo&quot;yo">yo</elem>
  <empty/>
  <chars>&amp;&lt;>"</chars>
  <my:elem xmlns:my="ns1">
    <my:elem>
      <my:other xmlns:my="ns2"/>
    </my:elem>
  </my:elem>
  <wo-ws>
    <first/>
    <second/>
  </wo-ws>
  <preserve xml:space="preserve">
      <yo/>
  </preserve>
</root>

To HTML

<root>
  <elem id="yo&quot;yo">yo</elem>
  <empty/>
  <chars>&amp;&lt;>"</chars>
  <my:elem xmlns:my="ns1">
    <my:elem>
      <my:other xmlns:my="ns2"/>
    </my:elem>
  </my:elem>
  <wo-ws>
    <first/>
    <second/>
  </wo-ws>
  <preserve xml:space="preserve">
      <yo/>
  </preserve>
</root>

To text, no indent

<root>
  <elem id="yo&quot;yo">yo</elem>
  <empty/>
  <chars>&amp;&lt;>"</chars>
  <my:elem xmlns:my="ns1">
    <my:elem>
      <my:other xmlns:my="ns2"/>
    </my:elem>
  </my:elem>
  <wo-ws><first/><second/></wo-ws>
  <preserve xml:space="preserve">
      <yo/>
  </preserve>
</root>

To HTML, no indent

<root>
  <elem id="yo&quot;yo">yo</elem>
  <empty/>
  <chars>&amp;&lt;>"</chars>
  <my:elem xmlns:my="ns1">
    <my:elem>
      <my:other xmlns:my="ns2"/>
    </my:elem>
  </my:elem>
  <wo-ws><first/><second/></wo-ws>
  <preserve xml:space="preserve">
      <yo/>
  </preserve>
</root>

To text, indent by 4

<root>
    <elem id="yo&quot;yo">yo</elem>
    <empty/>
    <chars>&amp;&lt;>"</chars>
    <my:elem xmlns:my="ns1">
        <my:elem>
            <my:other xmlns:my="ns2"/>
        </my:elem>
    </my:elem>
    <wo-ws>
        <first/>
        <second/>
    </wo-ws>
    <preserve xml:space="preserve">
      <yo/>
  </preserve>
</root>

To HTML, indent by 4

<root>
    <elem id="yo&quot;yo">yo</elem>
    <empty/>
    <chars>&amp;&lt;>"</chars>
    <my:elem xmlns:my="ns1">
        <my:elem>
            <my:other xmlns:my="ns2"/>
        </my:elem>
    </my:elem>
    <wo-ws>
        <first/>
        <second/>
    </wo-ws>
    <preserve xml:space="preserve">
      <yo/>
  </preserve>
</root>