Skip to content

Instantly share code, notes, and snippets.

@he-dev
Created October 16, 2017 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save he-dev/a035cc71d243162b5492b3848df0727f to your computer and use it in GitHub Desktop.
Save he-dev/a035cc71d243162b5492b3848df0727f to your computer and use it in GitHub Desktop.
var xml =
@"<?xml version=""1.0"" encoding=""UTF-8""?>
<report name=""ReportName"">
<agency name=""agency1"">
<office name=""office1""></office>
<office name=""office2""></office>
<office name=""office3""></office>
</agency>
<agency name=""agency2"">
<office name=""office1"">
<agent name=""agent Amy""></agent>
<address name=""address line""></address>
</office>
<office name=""office2""></office>
<office name=""office3""></office>
</agency>
<agency name=""agency3"">
<office name=""office1"">
<agent name=""agent Bettie"">
<subagent name=""sub-agent bob"">
<phone name=""456-789-1230""></phone>
</subagent>
<subagent name=""sub-agent billy""></subagent>
</agent>
<address name=""address line"">
<faxnumber name=""1234567890""></faxnumber>
</address>
</office>
<office name=""office2""></office>
<office name=""office3""></office>
</agency>
</report>";
var names =
XDocument
.Parse(xml)
.Root
.Descendants()
.Select(x => x.Attribute("name").Value)
.Dump();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment