Text values are interpreted by XLinq as an XText. so you can easily check if there is a node of type XText or by checking NodeType:
// get all text nodes var textNodes = document.DescendantNodes() .Where(x => x.NodeType == XmlNodeType.Text);
However, it seems to me that you only want to find that part of the text that seems a little lonely with the name textvalue. There is no real way to recognize this real, but unusual thing. You can either check if the parent has the name 'name', or if the textNode itself is alone or does not see:
// get 'lost' textnodes var lastTextNodes = document.DescendantNodes() .Where(x => x.NodeType == XmlNodeType.Text) .Where(x => x.Parent.Nodes().Count() > 1);
edit only one additional comment, I see that many people claim that this XML is invalid. I do not agree with that. Although not very pretty, it still acts in accordance with my knowledge (and validators)
source share