<Imovel>
etiketimin Child Nodes
numaralı kitabını okuman gerekiyor, sorun şu ki, XML dosyasımda 1 (bir) <Imovel>
etiketi var ve her bir <Imovel>
etiketi arasındaki fark var ID adı verilen bir özelliktir. Her belirli düğümün tüm XML alt düğümlerini oku
Bu
Her<Imovel>
etiketinin tüm etiketleri okumak gerek bir örnek
<Imoveis>
<Imovel id="555">
<DateImovel>2012-01-01 00:00:00.000</DateImovel>
<Pictures>
<Picture>
<Path>hhhhh</Path>
</Picture>
</Pictures>
// Here comes a lot of another tags
</Imovel>
<Imovel id="777">
<DateImovel>2012-01-01 00:00:00.000</DateImovel>
<Pictures>
<Picture>
<Path>tttt</Path>
</Picture>
</Pictures>
// Here comes a lot of another tags
</Imovel>
</Imoveis>
, ve benim <Imovel>
etiketinde yapmak her doğrulama sonunda başka bir doğrulama yapmanız gerekir.
Yani, ben, benim örnek çok iyi LINQ
hakkında anlıyorum ama uymayan 2 (iki) foreach
veya for
ve foreach
yapmanız gereken düşünmek
XmlReader rdr = XmlReader.Create(file);
XDocument doc2 = XDocument.Load(rdr);
ValidaCampos valida = new ValidaCampos();
//// Here I Count the number of `<Imovel>` tags exist in my XML File
for (int i = 1; i <= doc2.Root.Descendants().Where(x => x.Name == "Imovel").Count(); i++)
{
//// Get the ID attribute that exist in my `<Imovel>` tag
id = doc2.Root.Descendants().ElementAt(0).Attribute("id").Value;
foreach (var element in doc2.Root.Descendants().Where(x => x.Parent.Attribute("id").Value == id))
{
String name = element.Name.LocalName;
String value = element.Value;
}
}
Ama çok çalışmıyor iyi, foreach
ifademde benim <Picture>
etiketimden dolayı, üst etiketinde bir ID özelliği yok.
Birisi bu yöntemi yapmamda bana yardımcı olabilir mi?
'Ama bu ile ne demek açıklayabilir benim foreach statement.' içinde, çok iyi çalışmaz ekleyin? –
Evet, bu benim