|
January 28, 2002 Preserving White Spaces in XML Tips: January 2002
Yehuda Shiran, Ph.D.
|
|
Sometimes, you may want to preserve white spaces in the input XML file. You want the DOMDocument's xml property to reflect the input XML file as is, without any formatting. You can use the DOMDocument's preserveWhiteSpace property to control the parser behavior with respect to preservation of white spaces. By default, preserveWhiteSpace is false. If you load an XML file with these three lines:
you will get reformatted XML when echoing the xml property. But when you set preserveWhiteSpace to true in the above code:
you will get the original XML when echoing the xml property.
People who read this tip also read these tips: Look for similar tips by subject: |