当前位置: 首页>>代码示例>>C#>>正文


C# XmlNode.SelectSingleNodeFast方法代码示例

本文整理汇总了C#中System.Xml.XmlNode.SelectSingleNodeFast方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.SelectSingleNodeFast方法的具体用法?C# XmlNode.SelectSingleNodeFast怎么用?C# XmlNode.SelectSingleNodeFast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlNode的用法示例。


在下文中一共展示了XmlNode.SelectSingleNodeFast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractBody

 private static string ExtractBody(string body, string paramStart, XmlNode n)
 {
     string strStart = string.Empty;
     switch (paramStart)
     {
       case "Original Title":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartOTitle").InnerText);
     break;
       case "Translated Title":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartTTitle").InnerText);
     break;
       case "URL cover":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartImg").InnerText);
     break;
       case "Rate 1":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartRate").InnerText);
     break;
       case "Rate 2":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartRate2").InnerText);
     break;
       case "Synopsys":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartSyn").InnerText);
     break;
       case "Director":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartRealise").InnerText);
     break;
       case "Producer":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartProduct").InnerText);
     break;
       case "Actors":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartCredits").InnerText);
     break;
       case "Country":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartCountry").InnerText);
     break;
       case "Genre":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartGenre").InnerText);
     break;
       case "Year":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartYear").InnerText);
     break;
       case "Comment":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartComment").InnerText);
     break;
       case "Language":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartLanguage").InnerText);
     break;
       case "Tagline":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartTagline").InnerText);
     break;
       case "Certification":
     strStart = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStartCertification").InnerText);
     break;
     }
     if (strStart.Length > 0 && body.Length > 0)
       return body.Substring(body.IndexOf(strStart) + strStart.Length - 1);
     else
       return body;
 }
开发者ID:GuzziMP,项目名称:my-films,代码行数:59,代码来源:Grab.cs

示例2: Load

            // e.g. item = "Generic3"
            public string Load(XmlNode n, string item)
            {
                ScriptNode = n;
                string strGrabResult = string.Empty;

                #region load the parameters from script
                Stopwatch watch = new Stopwatch(); watch.Reset(); watch.Start();
                try
                {
                  DisplayName = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStart" + item).Attributes["DisplayName"].InnerText);
                }
                catch (Exception)
                {
                  DisplayName = item; // set this as default, if there is no DisplayName defined (yet) - backwardcompatibility !
                }

                Start = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStart" + item).InnerText);
                End = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyEnd" + item).InnerText);
                Index = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/Key" + item + "Index").InnerText);
                Page = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/Key" + item + "Page").InnerText);
                Param1 = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStart" + item).Attributes["Param1"].InnerText);
                Param2 = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/KeyStart" + item).Attributes["Param2"].InnerText);
                try
                {
                  Param3 = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/Key" + item + "RegExp").InnerText);
                }
                catch (Exception) { Param3 = ""; }

                try
                {
                  MaxItems = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/Key" + item + "MaxItems").InnerText);
                }
                catch (Exception) { MaxItems = ""; }

                try
                {
                  Language = XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/Key" + item + "Language").InnerText);
                }
                catch (Exception) { Language = ""; }

                try
                {
                  GrabRoles = (XmlConvert.DecodeName(n.SelectSingleNodeFast("Details/Key" + item + "GrabRoles").InnerText).ToLower() == "true");
                }
                catch (Exception)
                {
                  GrabRoles = false;
                }

                // new method for script loading:
                foreach (Data.GrabberScript.DetailRow detail in grabberscript.Detail.Where(detail => detail.Name == item))
                {
                  DisplayName = detail.Name.Length > 1 ? detail.Name : item;  // set this as default, if there is no DisplayName defined (yet) - backwardcompatibility !
                  Start = detail.Start;
                  End = detail.End;
                  Index = detail.Index;
                  Page = detail.SourcePage;
                  Param1 = detail.Param1;
                  Param2 = detail.Param2;
                  Param3 = detail.Param3;
                  MaxItems = detail.MaxItems;
                  Language = detail.Filter;
                  GrabRoles = detail.GetRoles;
                  break;
                }
                #endregion

                // load the Body page content first to get the data
                Body = PageBody(Page);

                #region grab the data from the Body - can be result or loading new page
                //// Overrides from MyFilms plugin:
                //if (!string.IsNullOrEmpty(personLimit)) MaxItems = personLimit.ToString();
                //if (!string.IsNullOrEmpty(getRoles)) GrabRoles = (getRoles.ToLower() == "true");

                // Overrides from MyFilms plugin:
                //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
                //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
                //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

                string allNames = string.Empty;
                string allRoles = string.Empty;
                if (Param1.Length > 0 || Param3.Length > 0)
                {
                  // strGrabResult = GrabUtil.FindWithAction(ExtractBody(Body, Index, n), Start, End, Param1, Param2, Param3, MaxItems, Language, out allNames, out allRoles).Trim();
                  strGrabResult = GrabUtil.FindWithAction(ExtractBody(Body, Index, n), Start, End, Param1, Param2, Param3, MaxItems, Language, out allNames, out allRoles, GrabRoles).Trim();
                  AllNames = allNames;
                  AllRoles = allRoles;
                }
                else
                {
                  strGrabResult = GrabUtil.Find(ExtractBody(Body, Index, n), Start, End).Trim();
                  AllNames = string.Empty;
                  AllRoles = string.Empty;
                }
                //strGrabResult = strGrabResult.Replace("\n", "");
                strGrabResult = GrabUtil.StripIllegalXmlChars(strGrabResult, "1.0");
                // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
                // strGrabResult = strGrabResult.Replace("\n", ""); // removed, as it seems, the "newlines" replacements for #LF# didn't work in AMC and MP
//.........这里部分代码省略.........
开发者ID:GuzziMP,项目名称:my-films,代码行数:101,代码来源:Grab.cs


注:本文中的System.Xml.XmlNode.SelectSingleNodeFast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。