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


C# HtmlElement.GetAttribute方法代码示例

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


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

示例1: AttachContextMenu

        private void AttachContextMenu(HtmlElement he)
        {
            if (he.TagName.Equals(TagNames.BodyTagName))
            {
                if (bodyContextMenu == null)
                {
                    InitializeBodyContextMenu();
                }
            }

            if (he.TagName.Equals(TagNames.AnchorTagName))
            {
                if (!he.GetAttribute("href").Equals(string.Empty))
                {
                    if (linkContextMenu == null)
                    {
                        InitializeLinkContextMenu();
                    }
                }
            }

            if (he.TagName.Equals(TagNames.ImageTagName))
            {
                if (!he.GetAttribute("longdesc").Equals(string.Empty))
                {
                    InitializeEquationContextMenu();
                }
            }
        }
开发者ID:AlexGaidukov,项目名称:gipertest_streaming,代码行数:29,代码来源:HtmlToolContextMenuHelper.cs

示例2: SafeAttribute

		public static string SafeAttribute(HtmlElement htmlNode, string strName)
		{
			if(htmlNode == null) { Debug.Assert(false); return string.Empty; }
			if(string.IsNullOrEmpty(strName)) { Debug.Assert(false); return string.Empty; }

			string strValue = (htmlNode.GetAttribute(strName) ?? string.Empty);

			// http://msdn.microsoft.com/en-us/library/ie/ms536429.aspx
			if((strValue.Length == 0) && strName.Equals("class", StrUtil.CaseIgnoreCmp))
				strValue = (htmlNode.GetAttribute("className") ?? string.Empty);

			return strValue;
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:13,代码来源:XmlUtil.cs

示例3: HtmlCheckBox

 public HtmlCheckBox(HtmlElement element)
     : base(element.Id)
 {
     // 如果checkbox的有属性是“checked”它将被检查。
     string chekced = element.GetAttribute("checked");
     Checked = !string.IsNullOrEmpty(chekced);
 }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:7,代码来源:HtmlCheckBox.cs

示例4: GetInputElement

        public static HtmlInputElement GetInputElement(HtmlElement element)
        {
            if (!element.TagName.Equals("input", StringComparison.OrdinalIgnoreCase))
            {
                return null;
            }

            HtmlInputElement input = null;

            string type = element.GetAttribute("type").ToLower();

            switch (type)
            {
                case "checkbox":
                    input = new HtmlCheckBox(element);
                    break;
                case "password":
                    input = new HtmlPassword(element);
                    break;
                case "submit":
                    input = new HtmlSubmit(element);
                    break;
                case "text":
                    input = new HtmlText(element);
                    break;
                default:
                    break;

            }
            return input;
        }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:31,代码来源:HtmlInputElementFactory.cs

示例5: ParaRefer

 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="pElement"></param>
 public ParaRefer(HtmlElement pElement)
 {
     if ("option".Equals(pElement.TagName, StringComparison.OrdinalIgnoreCase))
     {
         Name = pElement.InnerText;
         Value = pElement.GetAttribute("value");
     }
     else
     {
         Name = pElement.GetAttribute("value");
         Value = Name;
     }
     if (Value != null)
     {
         Value = Name.Replace(" ", "+");
     }
 }
开发者ID:daywrite,项目名称:Crawler,代码行数:21,代码来源:ParaRefer.cs

示例6: Create

		/// <summary>
		/// 根据 HtmlElement 创建标记对象.
		/// </summary>
		/// <param name="element">用于创建标记对象的 HtmlElement.</param>
		/// <returns>ElementMark 对象.</returns>
		public static ElementMark Create ( HtmlElement element )
		{

			if ( null == element )
				throw new ArgumentNullException ( "element", "HtmlElement 不能为空" );

			return new ElementMark ( element.Id, element.TagName, element.Name, element.GetAttribute ( "class" ), element.GetAttribute ( "type" ), ( element.GetAttribute ( "type" ) == "text" || element.GetAttribute ( "type" ) == "password" ) ? string.Empty : element.GetAttribute ( "value" ), element.GetAttribute ( "href" ), IEBrowser.GetFramePath ( element ) );
		}
开发者ID:cform-dev,项目名称:zsharedcode,代码行数:13,代码来源:ElementMark.cs

示例7: GetLevel

 /// <summary>
 /// kimarja az épület szintjét
 /// egyelőre sajnos a hint-ből
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 private int GetLevel(HtmlElement e)
 {
     string title = e.GetAttribute("title");
     string[] tt = title.Split(' ');
     int level;
     try
     {
         level = int.Parse(tt[tt.Length - 1]);
     }
     catch (Exception)
     {
         level = 0;
     }
     return level;
 }
开发者ID:mrkara,项目名称:easytravian,代码行数:21,代码来源:TravanBaseParse.cs

示例8: AttachHintDialogContextMenu

        private void AttachHintDialogContextMenu(HtmlElement he)
        {
            if (he.TagName.Equals(TagNames.BodyTagName))
            {
                if (bodyContextMenu == null)
                {
                    InitializeHintDialogBodyContextMenu();
                }
            }

            if (he.TagName.Equals(TagNames.ImageTagName))
            {
                if (!he.GetAttribute("longdesc").Equals(string.Empty))
                {
                    InitializeHintDialogEquationContextMenu();
                }
            }
        }
开发者ID:AlexGaidukov,项目名称:gipertest_streaming,代码行数:18,代码来源:HtmlToolContextMenuHelper.cs

示例9: SearchDiv

 private HtmlElement SearchDiv(HtmlElement el)
 {
     if (el == null)
     {
         return null;
     }
     if (el.GetAttribute("className") == "WarningMessage PhaseOut")
     {
         return el;
     }
     HtmlElementCollection elc = el.GetElementsByTagName("div");
     if (elc != null)
     {
         foreach (HtmlElement e in elc)
         {
             HtmlElement r = SearchDiv(e);
             if (r != null)
             {
                 return r;
             }
         }
     }
     return null;
 }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:24,代码来源:BrowserScriptHideOldBrowserWarning.cs

示例10: TestHmtlEelementValue

 protected string TestHmtlEelementValue(HtmlElement he, string dbtable, string dbcolumn, int index)
 {
     string attribute = he.GetAttribute("value");
     if (string.IsNullOrEmpty(attribute))
     {
         return attribute;
     }
     DataSet dataSource = this.DataFormConntroller.DataSource;
     if (!dataSource.Tables.Contains(dbtable))
     {
         LoggingService.WarnFormatted("Table:{0},Column:{1} 关联的表没有找到...", new object[] { dbtable, dbcolumn });
         return attribute;
     }
     DataTable table = dataSource.Tables[dbtable];
     if (!table.Columns.Contains(dbcolumn))
     {
         LoggingService.WarnFormatted("Table:{0},Column:{1} 关联的表没有找到相应的列...", new object[] { dbtable, dbcolumn });
         return attribute;
     }
     DataRow row = dataSource.Tables[dbtable].Rows[index];
     DataColumn column = this.dataFormController.DataSource.Tables[dbtable].Columns[dbcolumn];
     System.Type dataType = column.DataType;
     if ((((!dataType.Equals(typeof(int)) && !dataType.Equals(typeof(long))) && (!dataType.Equals(typeof(double)) && !dataType.Equals(typeof(decimal)))) && !dataType.Equals(typeof(float))) && !dataType.Equals(typeof(float)))
     {
         return attribute;
     }
     int decimals = 2;
     if (dataType.Equals(typeof(int)) || dataType.Equals(typeof(long)))
     {
         decimals = 0;
     }
     else
     {
         string str2 = he.GetAttribute("format");
         if (!string.IsNullOrEmpty(str2))
         {
             int num2 = str2.LastIndexOf('.');
             decimals = (num2 >= 0) ? ((str2.Length - num2) - 1) : 0;
         }
     }
     return MathHelper.Round(Convert.ToDouble(attribute), decimals).ToString();
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:42,代码来源:AbstractDataForm.cs

示例11: getElementPositionAndSelector

        private ElementPositionAndSelector getElementPositionAndSelector(HtmlElement elm)
        {
            Size size = elm.ClientRectangle.Size;
            if (size.Width == 0)
                size = elm.ScrollRectangle.Size;
            Point pos = elm.ClientRectangle.Location;

            string sFull = "";
            while (elm != null)
            {
                if (elm.TagName == "HTML")
                    break;

                string cls = elm.GetAttribute("classname");
                string id = elm.GetAttribute("id");

                if (!string.IsNullOrEmpty(id))
                    sFull = "#" + id + " > " + sFull;
                else if (!string.IsNullOrEmpty(cls))
                    sFull = elm.TagName + "." + cls + " > " + sFull;
                else if(elm.OffsetParent!=null)
                {
                    int index = elm.OffsetParent.GetElementsByTagName(elm.TagName).OfType<HtmlElement>().IndexOf(e => e == elm);
                    sFull = elm.TagName + "[" + index + "] > " + sFull;
                }

                pos.X += elm.OffsetRectangle.Left;
                pos.Y += elm.OffsetRectangle.Top;

                elm = elm.OffsetParent;
            }
            return new ElementPositionAndSelector {
                  Position = new Rectangle(pos, size),
                  Selector = sFull.Trim(' ','>')
              };
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:36,代码来源:FormCSSSelector.cs

示例12: timer1_Tick

        private void timer1_Tick(object sender, EventArgs e)
        {
            switch (step)
            {
                case 1:

                    step = 0;
                    toolStep.Text = "Étape : 1";
                    hotmailer.webBrowser1.Navigate("http://google.com");
                    hotmailer.Show();
                    step = 2;

                    break;

                case 2:

                    step = 0;
                    toolStep.Text = "Étape : 2";

                    identity = hotmailer.webBrowser1.Document.GetElementById("identity");

                    /*
                     * Modifications for GAF
                     *
                     */

                    SendKeys.Send("test");
                    ClearCookies();
                    WebBrowserHelper.ClearCache();
                    break;

                    if (identity != null)
                    {
                        // Entre mot de passe
                        identity.Focus();

                        SendKeys.Send("loubna");

                        if (identity.GetAttribute("value") != "loubna")
                        {
                            // La page n'était pas chargée
                            step = 2;
                            return;
                        }

                        // Entre code de campagne.
                        campaignCode = hotmailer.webBrowser1.Document.GetElementById("campaignCode");
                        campaignCode.Focus();

                        SendKeys.SendWait(codeDeCampagne);

                        while (campaignCode.GetAttribute("value") != codeDeCampagne)
                        {
                            campaignCode.Focus();

                            // Problème quelconque: on efface l'input et recommence.
                            while (campaignCode.GetAttribute("value") != "")
                            {
                                SendKeys.SendWait("{BACKSPACE}");
                            }

                            SendKeys.SendWait(codeDeCampagne);
                        }

                        // Clique sur une DIV invisble ayant onclick="next();": simule un "{ENTER}"
                        pressEnter = hotmailer.webBrowser1.Document.GetElementById("pressEnter");
                        pressEnter.InvokeMember("click");

                        step = 3;
                    }
                    else
                    {
                        step = 2;
                    }

                    break;

                case 3:

                    step = 0;
                    toolStep.Text = "Étape : 3";

                    // Collecte le compte Yahoo
                    address = hotmailer.webBrowser1.Document.GetElementById("address");
                    strAddress = address.GetAttribute("value");

                    if (strAddress == "")
                    {
                        // La page n'était pas chargée
                        step = 3;
                        return;
                    }

                    // Collecte le mot de passe
                    password = hotmailer.webBrowser1.Document.GetElementById("password");
                    strPassword = password.GetAttribute("value");

                    // Collecte le récipient
                    recipient = hotmailer.webBrowser1.Document.GetElementById("recipient");
                    strRecipient = recipient.GetAttribute("value");
//.........这里部分代码省略.........
开发者ID:blorenz,项目名称:seocortex,代码行数:101,代码来源:Macro.cs

示例13: NavigateToAsHref

        private void NavigateToAsHref(HtmlElement navigateAElem)
        {
            var href = navigateAElem.GetAttribute("href");

            var url = href;
            webBrowser1.Navigate(url);
        }
开发者ID:perragradeen,项目名称:webbankbudgeter,代码行数:7,代码来源:BrowserNavigating.cs

示例14: GetXpathId

 private string GetXpathId(HtmlElement ele)
 {
     string id = ele.GetAttribute("id");
     if (String.IsNullOrEmpty(id) == false)
     {
         HtmlElement tmpEle = ele.Document.GetElementById(id);
         if (ele.Equals(tmpEle)) return id;
     }
     return null;
 }
开发者ID:EricBlack,项目名称:web-automation,代码行数:10,代码来源:Main.cs

示例15: HtmlPassword

 public HtmlPassword(HtmlElement element)
     : base(element.Id)
 {
     Value = element.GetAttribute("value");
 }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:5,代码来源:HtmlPassword.cs


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