What are you trying to accomplish?
By setting preserveWhiteSpaceto true(optionally, the default), you tell libxml not to ignore text nodes that consist only of white space. However, at the same time, you are trying to format the XML file, which is really needed for nodes with spaces.
, , , <seg> ; libxml ; text 1, </seg> , node .
:
<?xml version="1.0" encoding="UTF-8"?>
<body>
<seg>
text 1
</seg>
<seg> text 2 </seg></body>
libxml, , </seg>, node.
$dom->preserveWhiteSpace = false;:
<?xml version="1.0" encoding="UTF-8"?>
<body>
<seg>
text 1
</seg>
<seg> text 2 </seg>
</body>
, libxml :
<?xml version="1.0" encoding="UTF-8"?>
<body>
<seg>
text 1
</seg>
<seg>
text 2
</seg>
</body>
<seg>.
, tidy, , , .