Reputation: 447
have an XML file like this:
<VS>
<Fields>
<Field Id="$1*">Column1</Field>
<Field Id="$2*">Column2</Field>
<Field Id="$3*">Column3</Field>
</Fields>
</VS>
When I use LINQ to XML using the following statement:
XDocument doc = XDocument.Parse(s);
var q = doc.Descendants("Fields").ToList();
I get a single entry in list as Column1Column2Column3, whereas I want it as 3 separate entities like Column1, Column2, Column3.
Can anyone help?
Upvotes: 2
Views: 6143
Reputation: 447
Just used the following code which returned list of strings.
var q = doc.Descendants("Field").Select(x => x.Value);
Thanks for all your suggestions!
Upvotes: 0
Reputation: 56162
Use Field
instead of Fields
:
var q = doc.Descendants("Field").ToList();
Upvotes: 4
Reputation: 2246
you should use XElement.Parse(BuildNode.InnerXml) instead of just passing the raw property in.
Upvotes: 0