Can somebody explain why is this xml
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="77" cityID="EE12345" cityDatum="15.2.2010. 11:28:35" />
</items>
when using query
Dim c = From items In st.Descendants _
Where items.@id IsNot Nothing _
Select New myStorage With {.id = items.@id, .cityID = items.@cityID, .cityDatum = items.@cityDatum}
storage = c.ToList
resulting in list(of myStorage) with two items - one with all empty (nothing) properties, second with values seen in xml above?
I've resolved the issue by adding
Where items.@id IsNot Nothing _
before Seletct New myStorage, but I have a feeling that I shouldn't be doing that.
I've recreated this in C#, storage.xml is exactly the same as specified above.
private void Form1_Load(object sender, EventArgs e)
{
XDocument st;
st = XDocument.Load("C:\\storage.xml");
Object c = from items in st.Descendants()
select new {id = items.Attribute("id"), cityID = items.Attribute("cityID"), cityDatum = items.Attribute("cityDatum")};
}
If you, as some can't replicate these results, here's a screenshot: