I have a simple XML file that looks something like:
<Institutions>
<FI name = "NameOne">
<longname>some text</longname>
<APIKey>some text</APIKey>
<connectstring>some text</connectstring>
</FI>
<FI name = "NameTwo">
<longname>some text</longname>
<APIKey>some text</APIKey>
<connectstring>some text </connectstring>
</FI>
</Institutions>
Using LINQ to XML I can grab the entire file, find all values for “longname”, “APIKey” and “connectstring” but I can not figure out how to find all the “name” values or how to grab only the three pieces of information underneath each FI name value. Just to be clear, I will have NO IDEA what the name= values are in advance.
I’m using:
XElement root = XElement.Load("c:\\directory\\Data_Config.xml");
and
IEnumerable<XElement> Fis =
from el in root.Elements("Institutions")
select el;
to load the file, as per the MSDN documentation. All of it’s references seem to imply knowledge of what the name value is that I would be querying.
I’ve googled, tried different Attribute/Element queries, all with no luck. I’m pretty sure it’s something simple but it’s evading me.
How do I get this data?
Thanks,
Jason
1 Answer