-
-
Save he-dev/a035cc71d243162b5492b3848df0727f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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