Verse ParseVerse(XmlTextReader reader) { bool finishedReading = false; Verse verse = new Verse( ); // get the verse number string verseNum = reader.GetAttribute("n"); verse.Number = int.Parse(verseNum); while (reader.Read( ) && finishedReading == false) { switch (reader.NodeType) { case XmlNodeType.Text: { verse.Text = reader.Value; break; } // find the close tag so we can end case XmlNodeType.EndElement: { finishedReading = true; break; } } } return(verse); }
Chapter ParseChapter(XmlTextReader reader) { bool finishedReading = false; Chapter chapter = new Chapter( ); // get the chapter number string chapterNum = reader.GetAttribute("n"); chapter.Number = int.Parse(chapterNum); while (reader.Read( ) && finishedReading == false) { switch (reader.NodeType) { case XmlNodeType.Element: { if (reader.Name == "v") { Verse verse = ParseVerse(reader); chapter.Verses.Add(verse); } break; } case XmlNodeType.EndElement: { finishedReading = true; break; } } } return(chapter); }