Well if you know the structure of your XML document and you already know in advance the nodes that you want you can use something very similar to this.
This will get the value that is in the node IE <someid2>blah</someid2> the value that is returned is blah.
If you want the properties of that node IE <someid2 prop1=blah2>blah</someid2> and you want the value of prop1 then you have to approach the problem differently and I can help you with that as well if you would like but hopefully this is what you are looking for.
static void Main()
{
List<string> files = new List<string>();
files = Directory.GetFiles(@"C:\Users\rpp0315\Desktop\Inbox").ToList();
foreach (var item in files)
{
var document = XDocument.Load(item);
var nodes = document.Descendants().Where(e => e.Name.LocalName.Equals("someid1") || e.Name.LocalName.Equals("someid3") || e.Name.LocalName.Equals("AccountNode"));
foreach (var node in nodes)
{
Console.WriteLine(node.Value.ToString());
}
}
Console.ReadKey();
}
No comments:
Post a Comment