Linq to Xml question: Struggling with a simple example

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am attempting to use XML for some simple formatting and embedded links. Im trying to parse the XML using Linq to Xml, but Im struggling with parsing a text "Value" with embedded elements in it. For example, this might be a piece of XML I want to parse:
Code:
<span><br/>
Essentially, I want to enumerate through the "Runs" in the Value of the description node. In the above example, there would be a text node with a value of "A plain ", followed by a "link" element, whose value is "table", followed by another text node whose
value is " with the green hat on it.".
How do I do this? I tried enumerating the root XElements Elements() enumeration, but that only returned the link element, as did Descendants(). DescendantNodes() did return all the nodes, but it also returned the subnodes of the link elements. In this case,
a text node containing "table", in addition to the element that contained it.

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; description<span style="color:Blue; >A plain <span style="color:Blue; <<span style="color:#A31515; link <span style="color:Red; ID<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; "<span style="color:Blue; >table<span style="color:Blue; </<span style="color:#A31515; link<span style="color:Blue; > with a green hat on it.<span style="color:Blue; </<span style="color:#A31515; description<span style="color:Blue; >
[/code]


View the full article
 
Back
Top