Exemplo n.º 1
0
        private void ParseTitleInfoTranslator(XmlReader xml, Translators translator)
        {
            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")
                    {
                        translator.First_name += xml.Value;
                    }
                    else if (lastNodeName == "last-name")
                    {
                        translator.Last_name += xml.Value;
                    }
                    else if (lastNodeName == "middle-name")
                    {
                        translator.Middle_name += xml.Value;
                    }
                    else if (lastNodeName == "nickname")
                    {
                        translator.Nickname += xml.Value;
                    }
                    else if (lastNodeName == "email")
                    {
                        translator.Email += xml.Value;
                    }
                    else if (lastNodeName == "home-page")
                    {
                        translator.Home_page += xml.Value;
                    }
                    else if (lastNodeName == "id")
                    {
                        translator.UniqID += xml.Value;
                    }
                    break;
                }
            }
        }
Exemplo n.º 2
0
        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();
        }