Reputation: 1033
So I have this:
<Configuration>
<Name>VendorCode</Name>
<Type>Value</Type>
<UISettings>
<Control>
<Name>DataFieldSelector</Name>
<Type>Value</Type>
</Control>
</UISettings>
<Values>
<Required>
<VendorCode />
</Required>
<Optional />
</Values>
</Configuration>
and from this, using C# I want a new XDocument
like this:
<Values>
<Required>
<VendorCode />
</Required>
<Optional />
</Values>
I know how to get individual elements and nodes, but not a whole chunk including children level.
Upvotes: 0
Views: 71
Reputation: 15865
var doc = XDocument.Parse(xmlstring);
var values = doc.Root.Element("Values");
Getting the Root
, then specifying that you want the Element
"Values" will return everything as you describe.
Here's a DotNet Fiddle
Upvotes: 1