I know this is a bit stupid, but XML I’m transforming sometimes has an element that is just a single or double whitespace. Like this:
Dim es1 = <Text> </Text>
When I try to get the .Value of this like Dim resultText = es1.Value, it’s just an empty string. This isn’t a problem if there is leading and/or trailing whitespace and at least one other character in the element.
Is there anyway to coerce .Value to give me white space if that is all there is?
Use
LoadOptions.PreserveWhitespacewhen you parse the XML. C# sample code:(Obviously this is available when using
Loadas well asParse, etc.)I don’t know how that fits in with VB XML literals, but I’ll assume that normally you’re actually parsing from a file etc 🙂