Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HolyQuran TranslationID="103" Writer="Maulana Mohammad Ali" Language="English" LanguageIsoCode="eng" Direction="ltr">
- <Chapter ChapterID="1" ChapterName="The Opening">
- <Verse VerseID="1"><![CDATA[In the name of Allah, the Beneficent, the Merciful.]]></Verse>
- <Verse VerseID="2"><![CDATA[Praise be to Allah, the Lord of the worlds,]]></Verse>
- <Verse VerseID="3"><![CDATA[The Beneficent, the Merciful,]]></Verse>
- <Verse VerseID="4"><![CDATA[Master of the day of Requital.]]></Verse>
- <Verse VerseID="5"><![CDATA[Thee do we serve and Thee do we beseech for help.]]></Verse>
- <Verse VerseID="6"><![CDATA[Guide us on the right path,]]></Verse>
- <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>
- </Chapter>
- public string getTranslation(int p1, int p2)
- {
- string translationPath = Path.Combine(Package.Current.InstalledLocation.Path, "Data/eglish-translation.xml");
- XDocument document = XDocument.Load(translationPath);
- var value = (from r in document.Descendants("Chapter").Where
- (r => ((int)r.Attribute("ChapterID") == p1)&&(int)r.Attribute("VerseId") == p2))
- select r.Element("Verse").Value).FirstOrDefault();
- return value;
- }
- var value = (from c in document.Descendants("Chapter")
- where (int)c.Attribute("ChapterID") == p1
- from v in c.Elements("Verse")
- where (int)v.Attribute("VerseID") == p2
- select (string)v).FirstOrDefault();
- var value = document.Descendants("Chapter")
- .Where(c => (int)c.Attribute("ChapterID") == p1)
- .SelectMany(c => c.Elements("Verse"))
- .Where(v => (int)v.Attribute("VerseID") == p2)
- .Select(v => (string)v)
- .FirstOrDefault();
- var xpath =
- String.Format("//Chapter[@ChapterID='{0}']/Verse[@VerseID='{1}']", p1, p2);
- var value = (string)document.XPathSelectElement(xpath);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement