The goal was to return the xml values but not returning anything:
using System;
using System.Xml.Linq;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Threading;
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
StreamReader strm = new StreamReader("C:\Users\Visita\Desktop\test.xml");
XDocument xd = XDocument.Load(strm);
var consulta = from p in xd.Descendants("tb")
where p.Element("simbolo").Value == "H"
select new
{
sa = Convert.ToString(p.Element("simbolo")),
nm = Convert.ToString(p.Element("nAtomic"))
};
foreach (var rs in consulta.ToArray())
{
Console.WriteLine(Convert.ToString(rs.nm));
}
Console.Read();
}
}
}
XML:
<?xml version="1.0" encoding="utf-8" ?>
<Itens>
<tb>
<simbolo>G</simbolo>
<nAtomic>56</nAtomic>
<valencia>5</valencia>
</tb>
<tb>
<simbolo>Ga</simbolo>
<nAtomic>565</nAtomic>
<valencia>55</valencia>
</tb>
</Itens>
Is not returning any value, what is the error?