Hi;
This code is in J# so it looks a little weird but you could change it to C#
in a couple of seconds.
The problem here is a single space node returns as an empty node:
public static void main(String[] args) throws Exception
{
XmlDocument doc = new XmlDocument();
doc.set_Preserv eWhitespace(tru e);
String xml = "<root><spa ce> </space></root>";
Encoding encoder = Encoding.GetEnc oding("utf-8");
doc.Load(new MemoryStream(en coder.GetBytes( xml)));
XPathNavigator nav = new XPathDocument(n ew
XmlNodeReader(d oc)).CreateNavi gator();
nav = nav.SelectSingl eNode("/root");
nav = nav.SelectSingl eNode("./space");
String str = nav.get_Value() ;
int len = str.length();
System.out.prin tln("value = {" + str + "}");
System.out.prin tln("length = " + len);
}
Any ideas how to get back the space that is the node value? I tried
doc.set_Preserv eWhitespace(tru e); both before and after the Load.
--
thanks - dave