In the code snippet below, I only have 1 element in the XML that has text data:
<element>like this</element>
All the other elements have attributes or nothing.
Why would my parsing below seem to indicate that ALL of my elements have “like this” as text data?
thx
StreamWriter sw = new StreamWriter(out_file_name_);
var xd = XDocument.Load(xml_template_file_name_);
foreach (XElement el in xd.Descendants())
sw.Write(el.Name + "-" + el.Value);
I think the answer is nesting, if your XML looks like this:
Then all elements except group2 will have ‘text’ as value.