private static string GetInitialTextFromNodes(ref XmlNode n)
{
string value = null;
if (n != null)
{
// don't consider whitespace
while (n.NodeType == XmlNodeType.Whitespace)
{
n = n.NextSibling;
if (n == null)
{
return(String.Empty);
}
}
if (XmlDataDocument.IsTextLikeNode(n) && (n.NextSibling == null || !XmlDataDocument.IsTextLikeNode(n.NextSibling)))
{
// don't use string builder if only one text node exists
value = n.Value;
n = n.NextSibling;
}
else
{
StringBuilder sb = new StringBuilder();
while (n != null && XmlDataDocument.IsTextLikeNode(n))
{
// Ignore non-significant whitespace nodes
if (n.NodeType != XmlNodeType.Whitespace)
{
sb.Append(n.Value);
}
n = n.NextSibling;
}
value = sb.ToString();
}
}
if (value == null)
{
value = String.Empty;
}
return(value);
}