예제 #1
0
파일: ReadFb2.cs 프로젝트: baznv/EditFb2
        private void ParseTitleInfoWriter(XmlReader xml, Writers writer)
        {
            string lastNodeName = "";

            while (xml.Read())
            {
                switch (xml.NodeType)
                {
                case XmlNodeType.Element:
                    if (xml.Name == "first-name")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "last-name")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "middle-name")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "nickname")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "email")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "home-page")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "id")
                    {
                        lastNodeName = xml.Name;
                    }
                    break;

                case XmlNodeType.Text:
                    if (lastNodeName == "first-name")
                    {
                        writer.First_name += xml.Value;
                    }
                    else if (lastNodeName == "last-name")
                    {
                        writer.Last_name += xml.Value;
                    }
                    else if (lastNodeName == "middle-name")
                    {
                        writer.Middle_name += xml.Value;
                    }
                    else if (lastNodeName == "nickname")
                    {
                        writer.Nickname += xml.Value;
                    }
                    else if (lastNodeName == "email")
                    {
                        writer.Email += xml.Value;
                    }
                    else if (lastNodeName == "home-page")
                    {
                        writer.Home_page += xml.Value;
                    }
                    else if (lastNodeName == "id")
                    {
                        writer.UniqID += xml.Value;
                    }
                    break;
                }
            }
        }
예제 #2
0
        private void CreateBook(string str)
        {
            string description = GetSubstring("description", str);
            {
                string titleInfo = GetSubstring("title-info", description);
                {
                    ti_genre = GetFewSubstring("genre", titleInfo);
                    List <string> lstWriter = GetFewSubstring("author", titleInfo);
                    {
                        ti_writer = new List <Writers>();
                        foreach (var item in lstWriter)
                        {
                            Writers writer = new Writers()
                            {
                                First_name  = GetSubstring("first_name", item),
                                Last_name   = GetSubstring("last_name", item),
                                Middle_name = GetSubstring("middle_name", item),
                                Nickname    = GetSubstring("nickname", item),
                                Email       = GetSubstring("email", item),
                            };
                            ti_writer.Add(writer);
                        }
                    }
                    ti_book_title = GetSubstring("book-title", titleInfo);
                    ti_annotation = GetSubstring("annotation", titleInfo);
                    ti_date       = GetSubstring("date", titleInfo);
                    ti_coverpage  = GetSubstring("coverpage", titleInfo);
                    ti_lang       = GetSubstring("lang", titleInfo);
                    ti_src_lang   = GetSubstring("src-lang", titleInfo);
                    //ti_translator = GetFewSubstring("translator", titleInfo);
                    List <string> lstTranslator = GetFewSubstring("translator", titleInfo);
                    {
                        ti_translator = new List <Translator>();
                        foreach (var item in lstTranslator)
                        {
                            Translator translator = new Translator()
                            {
                                First_name  = GetSubstring("first_name", item),
                                Last_name   = GetSubstring("last_name", item),
                                Middle_name = GetSubstring("middle_name", item),
                                Nickname    = GetSubstring("nickname", item),
                                Email       = GetSubstring("email", item),
                            };
                            ti_translator.Add(translator);
                        }
                    }

                    ti_sequence = GetFewSubstring("sequence", titleInfo);
                }
                string srcTitleInfo = GetSubstring("src-title-info", description);
                { }
                string documentInfo = GetSubstring("document-info", description);
                {
                    List <string> lstAuthor = GetFewSubstring("author", documentInfo);
                    {
                        di_author = new List <Author>();
                        foreach (var item in lstAuthor)
                        {
                            Author author = new Author()
                            {
                                First_name = GetSubstring("first_name", item),
                                //Last_name = GetSubstring("last_name", item),
                                //Middle_name = GetSubstring("middle_name", item),
                                //Nickname = GetSubstring("nickname", item),
                                //Email = GetSubstring("email", item),
                            };
                            di_author.Add(author);
                        }
                    }

                    di_program_used = GetSubstring("program-used", documentInfo);
                    di_date         = GetSubstring("date", documentInfo);
                    di_src_url      = GetFewSubstring("src-url", documentInfo);
                    di_src_ocr      = GetSubstring("src-ocr", documentInfo);
                    di_id           = GetSubstring("id", documentInfo);
                    di_version      = GetSubstring("version", documentInfo);
                    di_history      = GetSubstring("history", documentInfo);
                }
                string publishInfo = GetSubstring("publish-info", description);
                {
                    pi_book_name = GetSubstring("history", documentInfo);
                    pi_publisher = GetSubstring("publisher", documentInfo);
                    pi_city      = GetSubstring("city", documentInfo);
                    pi_year      = GetSubstring("year", documentInfo);
                }
                string customInfo = GetSubstring("custom-info", description);
            }
        }
예제 #3
0
파일: ReadFb2.cs 프로젝트: baznv/EditFb2
        private void ParseTitleInfo(XmlReader xml)
        {
            string lastNodeName = "";

            while (xml.Read())
            {
                switch (xml.NodeType)
                {
                case XmlNodeType.Element:
                    if (xml.Name == "annotation")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "book-title")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "keywords")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "lang")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "src-lang")
                    {
                        lastNodeName = xml.Name;
                    }
                    else if (xml.Name == "author")
                    {
                        Writers writer = new Writers();
                        ParseTitleInfoWriter(xml.ReadSubtree(), writer);
                        TitleInfo_writers.Add(writer);
                    }
                    else if (xml.Name == "translator")
                    {
                        Translators translator = new Translators();
                        ParseTitleInfoTranslator(xml.ReadSubtree(), translator);
                        TitleInfo_translators.Add(translator);
                    }
                    else if (xml.Name == "coverpage")
                    {
                        if (xml.HasAttributes)
                        {
                            while (xml.MoveToNextAttribute())
                            {
                                if (xml.Name == "image")
                                {
                                    TitleInfo_coverpage = xml.Value;
                                    break;
                                }
                            }
                        }
                    }

                    break;

                case XmlNodeType.Text:
                    if (lastNodeName == "annotation")
                    {
                        TitleInfo_annotation += xml.Value;
                    }
                    else if (lastNodeName == "book-title")
                    {
                        TitleInfo_book_title = xml.Value;
                    }
                    else if (lastNodeName == "keywords")
                    {
                        TitleInfo_keyword = xml.Value;
                    }
                    else if (lastNodeName == "lang")
                    {
                        TitleInfo_lang = xml.Value;
                    }
                    else if (lastNodeName == "src-lang")
                    {
                        TitleInfo_src_lang = xml.Value;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (xml.Name == "member")
                    {
                    }
                    break;
                }
            }
            //TitleInfo_date = elTitleInfo.Element(ns + "date")?.Attribute("value") == null ? elTitleInfo.Element(ns + "date")?.Value : elTitleInfo.Element(ns + "date")?.Attribute("value")?.Value;
            //TitleInfo_coverpage = elTitleInfo.Element(ns + "coverpage")?.Element(ns + "image")?.Attributes()?.Select(p => p.Value.Split('#')[1]).ToList()[0];

            //TitleInfo_genres = elTitleInfo.Elements(ns + "genre").Select(p => p.Value).ToList();
        }