'Get all the text under a element

My xml looks like this

<Element> text <B>text<B></Element>

Unknown number of B tags or tags even of a different name.

How do i get the text from these? so it would be like this

text text

using linq to xml



Solution 1:[1]

As you need any children not just the "B"s if root is your Element tag as as XElement

var text = string.Empty;
root.DescendentsAndSelf().Select(x => text += x.Value);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 halfer