PDA

View Full Version : مشکل در خواندن اطلاعات از xml



NIMA_1981
پنج شنبه 18 اسفند 1390, 12:48 عصر
سلام دوستان
من یک فایل xml دارم به این شکل

<?xml version="1.0" encoding="utf-8" ?>
<quran type="metadata" version="1.0" copyright="(C) 20118-2012 naeim.ir" license="cc-by">
<Page1 alias="chapters" >
<aya index="1" Ayanum="1" Qtext="الْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ" bismillah="true" sname="الفاتحة" sumaya="6"/>
<aya index="2" Ayanum="2" Qtext="الرَّحْمَٰنِ الرَّحِيمِ" />
<aya index="3" Ayanum="3" Qtext="مَالِكِ يَوْمِ الدِّينِ" />
<aya index="4" Ayanum="4" Qtext="إِيَّاكَ نَعْبُدُ وَإِيَّاكَ نَسْتَعِينُ"/>
<aya index="5" Ayanum="5" Qtext="اهْدِنَا الصِّرَاطَ الْمُسْتَقِيمَ" />
<aya index="6" Ayanum="6" Qtext="صِرَاطَ الَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِ الْمَغْضُوبِ عَلَيْهِمْ وَلَا الضَّالِّينَ" />
</Page1>
</quran>

حالا به این کد میخوام اینو بخونم توی یک لیست قرار بدم



XDocument data = XDocument.Load(HttpContext.Current.Server.MapPath("quran.xml"));
XElement quran = data.Element("quran");
XElement pages = quran.Element("Page1");
return (from c in pages.Descendants("aya")
select new SoraData1(){
Index = (int)c.Attribute("index"),
AyaNum= (int)c.Attribute("ayanum"),
Qtext = (string)c.Attribute("Qtext").Value,
bismillah = (bool)c.Attribute("bismillah"),
Sname = (string)c.Attribute("sname").Value,

Sumaya = (int)c.Attribute("sumaya")
}).ToList();



public class SoraData1{
public int Index {get; set;}
public int AyaNum {get; set;}
public string Qtext {get; set;}
public bool bismillah {get; set;}
public string Sname {get; set;}
public int Sumaya {get; set;}
}


اما این خطا رو میده
83843
با نشکر