Beispiel #1
0
        private static EpubNavigationDocAuthor ReadNavigationDocAuthor(XElement docAuthorNode)
        {
            EpubNavigationDocAuthor result = new EpubNavigationDocAuthor();

            foreach (XElement textNode in docAuthorNode.Elements())
            {
                if (String.Compare(textNode.Name.LocalName, "text", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    result.Add(textNode.Value);
                }
            }
            return(result);
        }
        private static EpubNavigationDocAuthor ReadNavigationDocAuthor(XmlNode docAuthorNode)
        {
            EpubNavigationDocAuthor result = new EpubNavigationDocAuthor();

            foreach (XmlNode textNode in docAuthorNode.ChildNodes)
            {
                if (String.Compare(textNode.LocalName, "text", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    result.Add(textNode.InnerText);
                }
            }
            return(result);
        }
Beispiel #3
0
        private static async Task <List <EpubNavigationDocAuthor> > ReadNavigationAuthorsAsync(XmlReader reader)
        {
            List <EpubNavigationDocAuthor> result = new List <EpubNavigationDocAuthor>();
            bool authorFound = await reader.ReadToFollowingAsync("docAuthor", "http://www.daisy.org/z3986/2005/ncx/");

            ////we don't really care if there is no authors mentioned in toc file... But we could save a warning to a log file if any
            //TO-DO: This code is very week as I don`t have any reliable tools to extract all of docAuthor nodes and parse them.
            //So I`m relying on basic EPUB structure that demands that file should have at least one navMap node and all docAuthors should come before it
            //I think I should rewrite this code later using LINQ to XML

            while (await reader.ReadAsync() && !(reader.IsStartElement() && reader.LocalName == "navMap"))
            {
                EpubNavigationDocAuthor author = new EpubNavigationDocAuthor();
                if (reader.NodeType == XmlNodeType.Text)
                {
                    author.Add(reader.Value);
                    result.Add(author);
                }
            }

            return(result);
        }
        private static async Task<List<EpubNavigationDocAuthor>> ReadNavigationAuthorsAsync(XmlReader reader)
        {
            List<EpubNavigationDocAuthor> result = new List<EpubNavigationDocAuthor>();
            bool authorFound = await reader.ReadToFollowingAsync("docAuthor", "http://www.daisy.org/z3986/2005/ncx/");

            ////we don't really care if there is no authors mentioned in toc file... But we could save a warning to a log file if any
            //TO-DO: This code is very week as I don`t have any reliable tools to extract all of docAuthor nodes and parse them.
            //So I`m relying on basic EPUB structure that demands that file should have at least one navMap node and all docAuthors should come before it
            //I think I should rewrite this code later using LINQ to XML

            while (await reader.ReadAsync() && !(reader.IsStartElement() && reader.LocalName == "navMap"))
            {
                EpubNavigationDocAuthor author = new EpubNavigationDocAuthor();
                if (reader.NodeType == XmlNodeType.Text)
                {
                    author.Add(reader.Value);
                    result.Add(author);
                }

            }

            return result;

        }
Beispiel #5
0
 private static EpubNavigationDocAuthor ReadNavigationDocAuthor(XmlNode docAuthorNode)
 {
     EpubNavigationDocAuthor result = new EpubNavigationDocAuthor();
     foreach (XmlNode textNode in docAuthorNode.ChildNodes)
         if (String.Compare(textNode.LocalName, "text", StringComparison.OrdinalIgnoreCase) == 0)
             result.Add(textNode.InnerText);
     return result;
 }