A
Alberto
In a xml file, I have a first element (appears only one time) with this
label:
<config>
<fuentepalabras>...</fuentepalabras>
<fuenteelementos>...</fuenteelementos>
</config>
After this first element, there are several called <elemento>:
<elemento>
...
</elemento>
....
<elemento>
...
</elemento>
I'm reading this elements with this code:
IEnumerable<Elemento> listaElementos;
XDocument doc = XDocument.Load(Nombre);
listaElementos =
from elemento in doc.Root.Elements("elemento")
select new Elemento()
{
Location = new Point((int)elemento.Element("x"),
(int)elemento.Element("y")),
Id = (int)elemento.Element("id"),
Text = (string)elemento.Element("texto"),
ListaHijos = (from hijo in elemento.Element("hijos").Elements("hijo")
select (int)hijo).ToList(),
ListaPadres = (from padre in elemento.Element("padres").Elements("padre")
select (int)padre).ToList()
};
My questión is how can I read the first element called <elemento>. I don't
know how to work with the XDocument. Thank you very much
label:
<config>
<fuentepalabras>...</fuentepalabras>
<fuenteelementos>...</fuenteelementos>
</config>
After this first element, there are several called <elemento>:
<elemento>
...
</elemento>
....
<elemento>
...
</elemento>
I'm reading this elements with this code:
IEnumerable<Elemento> listaElementos;
XDocument doc = XDocument.Load(Nombre);
listaElementos =
from elemento in doc.Root.Elements("elemento")
select new Elemento()
{
Location = new Point((int)elemento.Element("x"),
(int)elemento.Element("y")),
Id = (int)elemento.Element("id"),
Text = (string)elemento.Element("texto"),
ListaHijos = (from hijo in elemento.Element("hijos").Elements("hijo")
select (int)hijo).ToList(),
ListaPadres = (from padre in elemento.Element("padres").Elements("padre")
select (int)padre).ToList()
};
My questión is how can I read the first element called <elemento>. I don't
know how to work with the XDocument. Thank you very much