Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <HolyQuran TranslationID="103" Writer="Maulana Mohammad Ali" Language="English" LanguageIsoCode="eng" Direction="ltr">
  2. <Chapter ChapterID="1" ChapterName="The Opening">
  3. <Verse VerseID="1"><![CDATA[In the name of Allah, the Beneficent, the Merciful.]]></Verse>
  4. <Verse VerseID="2"><![CDATA[Praise be to Allah, the Lord of the worlds,]]></Verse>
  5. <Verse VerseID="3"><![CDATA[The Beneficent, the Merciful,]]></Verse>
  6. <Verse VerseID="4"><![CDATA[Master of the day of Requital.]]></Verse>
  7. <Verse VerseID="5"><![CDATA[Thee do we serve and Thee do we beseech for help.]]></Verse>
  8. <Verse VerseID="6"><![CDATA[Guide us on the right path,]]></Verse>
  9. <Verse VerseID="7"><![CDATA[The path of those upon whom Thou has bestowed favours, Not those upon whom wrath is brought down, nor those who go astray.]]></Verse>
  10. </Chapter>
  11.  
  12. public string getTranslation(int p1, int p2)
  13. {
  14. string translationPath = Path.Combine(Package.Current.InstalledLocation.Path, "Data/eglish-translation.xml");
  15. XDocument document = XDocument.Load(translationPath);
  16. var value = (from r in document.Descendants("Chapter").Where
  17. (r => ((int)r.Attribute("ChapterID") == p1)&&(int)r.Attribute("VerseId") == p2))
  18. select r.Element("Verse").Value).FirstOrDefault();
  19.  
  20.  
  21. return value;
  22. }
  23.  
  24. var value = (from c in document.Descendants("Chapter")
  25. where (int)c.Attribute("ChapterID") == p1
  26. from v in c.Elements("Verse")
  27. where (int)v.Attribute("VerseID") == p2
  28. select (string)v).FirstOrDefault();
  29.  
  30. var value = document.Descendants("Chapter")
  31. .Where(c => (int)c.Attribute("ChapterID") == p1)
  32. .SelectMany(c => c.Elements("Verse"))
  33. .Where(v => (int)v.Attribute("VerseID") == p2)
  34. .Select(v => (string)v)
  35. .FirstOrDefault();
  36.  
  37. var xpath =
  38. String.Format("//Chapter[@ChapterID='{0}']/Verse[@VerseID='{1}']", p1, p2);
  39. var value = (string)document.XPathSelectElement(xpath);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement