XmlDocument PreserveWhitespace

S

Shaun Dore

Hi,

What is the Xml DOM PreserveWhitespace property supposed to do? I thought
that setting it to false would remove the superfluous white spaces? For
instance, in the following code I would expect the spaces after "for rent"
would be stripped, but it's not the case. I know workarounds for this but
I'm pretty sure in the old MSXML2.DomDocument this used to work very well.

XmlDocument oXml = new XmlDocument();
oXml.PreserveWhitespace = false;
oXml.LoadXml("<?xml version='1.0'?><test><space>this space for rent
</space></test>");

Documentation:

"If PreserveWhitespace is true before Load or LoadXml is called, white space
nodes are preserved; otherwise, if this property is false, significant white
space is preserved, white space is not."

Regards,
Shaun.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,253
Latest member
BlytheFant

Latest Threads

Top