Exemple #1
0
        // GetThumbInfo で取得した xml を解析してメンバーに設定
        public void ParseGetThumbInfo(string xml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            XmlElement element = doc.DocumentElement;

            if (element.Attributes["status"].Value == "ok")
            {
                status_ = Status.OK;
                for (XmlNode node = element.FirstChild.FirstChild;
                     node != null; node = node.NextSibling)
                {
                    switch (node.Name)
                    {
                    case "video_id":
                        video_id = IJStringUtil.UnescapeHtml(node.InnerText);
                        break;

                    case "title":
                        title = IJStringUtil.UnescapeHtml(node.InnerText);
                        break;

                    case "description":
                        description = IJStringUtil.UnescapeHtml(node.InnerText);
                        break;

                    case "thumbnail_url":
                        thumbnail_url = IJStringUtil.UnescapeHtml(node.InnerText);
                        break;

                    case "first_retrieve":
                        submit_date = DateTime.ParseExact(IJStringUtil.UnescapeHtml(node.InnerText), "yyyy-MM-ddTHH:mm:ss+09:00", null);
                        break;

                    case "view_counter":
                        point.view = int.Parse(IJStringUtil.UnescapeHtml(node.InnerText));
                        break;

                    case "comment_num":
                        point.res = int.Parse(IJStringUtil.UnescapeHtml(node.InnerText));
                        break;

                    case "mylist_counter":
                        point.mylist = int.Parse(IJStringUtil.UnescapeHtml(node.InnerText));
                        break;

                    case "length":
                        length = IJStringUtil.UnescapeHtml(node.InnerText);
                        break;

                    case "last_res_body":
                        last_res_body = IJStringUtil.UnescapeHtml(node.InnerText);
                        break;

                    case "user_id":
                        user_id = IJStringUtil.UnescapeHtml(node.InnerText);
                        break;

                    case "tags":
                        if (node.Attributes["domain"] != null && node.Attributes["domain"].Value == "jp")
                        {
                            for (XmlNode tagnode = node.FirstChild;
                                 tagnode != null; tagnode = tagnode.NextSibling)
                            {
                                bool is_lock;
                                if (tagnode.Attributes["lock"] != null && tagnode.Attributes["lock"].Value == "1")
                                {
                                    is_lock = true;
                                }
                                else
                                {
                                    is_lock = false;
                                }
                                tag_set.Add(IJStringUtil.UnescapeHtml(tagnode.InnerText), is_lock);
                            }
                        }
                        break;
                    }
                }
            }
            else
            {
                if (element.FirstChild.FirstChild.InnerText == "NOT_FOUND")
                {
                    status_ = Status.NOT_FOUND;
                }
                else if (element.FirstChild.FirstChild.InnerText == "DELETED")
                {
                    status_ = Status.DELETED;
                }
                else
                {
                    status_ = Status.OTHER;
                }
            }
        }