private XmlElement GetLastPageForInsertingNewContent(HtmlDom printingDom)
{
var lastPage =
printingDom.RawDom.SelectSingleNode("/html/body//div[contains(@class, 'bloom-page') and not(contains(@class,'bloom-frontMatter')) and not(contains(@class,'bloom-backMatter'))][last()]") as XmlElement;
if(lastPage==null)
{
//currently nothing but front and back matter
var lastFrontMatter= printingDom.RawDom.SelectSingleNode("/html/body//div[contains(@class,'bloom-frontMatter')][last()]") as XmlElement;
if(lastFrontMatter ==null)
throw new ApplicationException("GetLastPageForInsertingNewContent() found no content pages nor frontmatter");
return lastFrontMatter;
}
else
{
return (XmlElement) lastPage;
}
}