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


C# HtmlAgilityPack.HtmlAttribute类代码示例

本文整理汇总了C#中HtmlAgilityPack.HtmlAttribute的典型用法代码示例。如果您正苦于以下问题:C# HtmlAttribute类的具体用法?C# HtmlAttribute怎么用?C# HtmlAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Clone

		/// <summary>
		/// Creates a duplicate of this attribute.
		/// </summary>
		/// <returns>The cloned attribute.</returns>
		public HtmlAttribute Clone()
		{
			HtmlAttribute att = new HtmlAttribute(_ownerdocument);
			att.Name = Name;
			att.Value = Value;
			return att;
		}
开发者ID:GitHubXur,项目名称:Fine-UI,代码行数:11,代码来源:HtmlAttribute.cs

示例2: HtmlAttributeWrapper

        public HtmlAttributeWrapper(HtmlAttribute wrappedAttribute)
        {
            if(wrappedAttribute == null)
                throw new ArgumentNullException("wrappedAttribute");

            _wrappedAttribute = wrappedAttribute;
        }
开发者ID:CharlieBP,项目名称:AjaxControlToolkit,代码行数:7,代码来源:HtmlAttributeWrapper.cs

示例3: MakeAbsolute

 private static void MakeAbsolute(HtmlAttribute attr, Uri baseUrl) {
     var url = attr.Value;
     if (!url.StartsWith("http:", StringComparison.OrdinalIgnoreCase)
         && !url.StartsWith("https:", StringComparison.OrdinalIgnoreCase)
         && Uri.IsWellFormedUriString(url, UriKind.Relative)) {
         attr.Value = new Uri(baseUrl, url).ToString();
     }
 }
开发者ID:omidam81,项目名称:Ver1.0,代码行数:8,代码来源:RelativeUrlHtmlFilter.cs

示例4: ExtractModel

        private string ExtractModel(string make, HtmlAttribute htmlAttribute)
        {
            if (htmlAttribute != null)
            {
                var stringToReplace = string.Format(@"/usedcar/{0}__", make);
                return htmlAttribute.Value.Replace(stringToReplace, string.Empty).Replace(".html", string.Empty);
            }

            return string.Empty;
        }
开发者ID:badokun,项目名称:vehicleanalysis,代码行数:10,代码来源:GooNetArgumentBuilder.cs

示例5: Prepend

        /// <summary>
        /// Inserts the specified attribute as the first node in the collection.
        /// </summary>
        /// <param name="newAttribute">The attribute to insert. May not be null.</param>
        /// <returns>The prepended attribute.</returns>
        public HtmlAttribute Prepend(HtmlAttribute newAttribute)
        {
            if (newAttribute == null)
            {
                throw new ArgumentNullException("newAttribute");
            }

            _hashitems[newAttribute.Name] = newAttribute;
            newAttribute._ownernode = _ownernode;
            _items.Insert(0, newAttribute);

            _ownernode._innerchanged = true;
            _ownernode._outerchanged = true;
            return newAttribute;
        }
开发者ID:mburns1,项目名称:googlefinance,代码行数:20,代码来源:HtmlAttributeCollection.cs

示例6: RetrieveImageUrl

 private string RetrieveImageUrl(HtmlAttribute htmlAttribute)
 {
     try
     {
         var url = htmlAttribute.Value;
         var htmlDocument = _htmlWeb.Load(url);
         if (htmlDocument.DocumentNode != null)
         {
             var node = htmlDocument.DocumentNode.SelectSingleNode("//*[@id = 'frontCover']");
             if (node != null)
             {
                 return string.Format("{0}{1}", BaseUrl, node.Attributes["src"].Value);
             }
         }
         return null;
     }
     catch (Exception)
     {
         return null;
     }
 }
开发者ID:moorcroftlad,项目名称:StockSharer,代码行数:21,代码来源:TheGamesDbScraper.cs

示例7: HtmlAttributeAdapter

 internal HtmlAttributeAdapter( AP.HtmlAttribute attribute )
 {
   _attribute = attribute;
 }
开发者ID:ajayumi,项目名称:Jumony,代码行数:4,代码来源:HtmlAttributeAdapter.cs

示例8: Remove

 /// <summary>
 /// Removes a given attribute from the list.
 /// </summary>
 /// <param name="attribute">The attribute to remove. May not be null.</param>
 public void Remove(HtmlAttribute attribute)
 {
     if (attribute == null)
     {
         throw new ArgumentNullException("attribute");
     }
     int index = GetAttributeIndex(attribute);
     if (index == -1)
     {
         throw new IndexOutOfRangeException();
     }
     RemoveAt(index);
 }
开发者ID:fuenby,项目名称:css-agility,代码行数:17,代码来源:HtmlAttributeCollection.cs

示例9: GetAttributeIndex

 internal int GetAttributeIndex(HtmlAttribute attribute)
 {
     if (attribute == null)
     {
         throw new ArgumentNullException("attribute");
     }
     for (int i = 0; i < _items.Count; i++)
     {
         if (((HtmlAttribute)_items[i]) == attribute)
             return i;
     }
     return -1;
 }
开发者ID:fuenby,项目名称:css-agility,代码行数:13,代码来源:HtmlAttributeCollection.cs

示例10: CleanAttributeValues

        /// <summary>
        /// This removes the vulnerable keywords and make values safe by html encoding and html character escaping.
        /// </summary>        
        /// <param name="attribute">Attribute that contain values that need to check and clean.</param>
        private void CleanAttributeValues(HapHtmlAttribute attribute)
        {
            if (CleanAttributes)
            {
                attribute.Value = HttpUtility.HtmlEncode(attribute.Value);

                attribute.Value = Regex.Replace(attribute.Value, @"\s*j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*", "", RegexOptions.IgnoreCase);
                attribute.Value = Regex.Replace(attribute.Value, @"\s*s\s*c\s*r\s*i\s*p\s*t\s*", "", RegexOptions.IgnoreCase);

                if (attribute.Name.ToLower() == "style")
                {
                    attribute.Value = Regex.Replace(attribute.Value, @"\s*e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*", "", RegexOptions.IgnoreCase);
                    attribute.Value = Regex.Replace(attribute.Value, @"\s*b\s*e\s*h\s*a\s*v\s*i\s*o\s*r\s*", "", RegexOptions.IgnoreCase);
                }

                if (attribute.Name.ToLower() == "href" || attribute.Name.ToLower() == "src")
                {
                    attribute.Value = Regex.Replace(attribute.Value, @"\s*m\s*o\s*c\s*h\s*a\s*", "", RegexOptions.IgnoreCase);
                }
            }

            // HtmlEntity Escape
            if (EncodeHtmlEntities)
            {
                // Ensure no double encoding goes on - reverse the ones done by the CreoleParser
                string value = attribute.Value;
                value = value.Replace("&#x32;", "\"");
                value = value.Replace("&#x3C;", "<");
                value = value.Replace("&#x3E;", ">");
                value = value.Replace("&#x26;", "&");
                value = value.Replace("&#x27;", "'");
                attribute.Value = value;

                StringBuilder sbAttributeValue = new StringBuilder();
                foreach (char c in attribute.Value.ToCharArray())
                {
                    sbAttributeValue.Append(EncodeCharacterToHtmlEntityEscape(c));
                }

                attribute.Value = sbAttributeValue.ToString();
            }
        }
开发者ID:NaseUkolyCZ,项目名称:roadkill,代码行数:46,代码来源:MarkupSanitizer.cs

示例11: Parse

 private void Parse()
 {
   int num = 0;
   if (this.OptionComputeChecksum)
     this._crc32 = new Crc32();
   this.Lastnodes = new Dictionary<string, HtmlNode>();
   this._c = 0;
   this._fullcomment = false;
   this._parseerrors = new List<HtmlParseError>();
   this._line = 1;
   this._lineposition = 1;
   this._maxlineposition = 1;
   this._state = HtmlDocument.ParseState.Text;
   this._oldstate = this._state;
   this._documentnode._innerlength = this.Text.Length;
   this._documentnode._outerlength = this.Text.Length;
   this._remainderOffset = this.Text.Length;
   this._lastparentnode = this._documentnode;
   this._currentnode = this.CreateNode(HtmlNodeType.Text, 0);
   this._currentattribute = (HtmlAttribute) null;
   this._index = 0;
   this.PushNodeStart(HtmlNodeType.Text, 0);
   while (this._index < this.Text.Length)
   {
     this._c = (int) this.Text[this._index];
     this.IncrementPosition();
     switch (this._state)
     {
       case HtmlDocument.ParseState.Text:
         if (!this.NewCheck())
           continue;
         continue;
       case HtmlDocument.ParseState.WhichTag:
         if (!this.NewCheck())
         {
           if (this._c == 47)
           {
             this.PushNodeNameStart(false, this._index);
           }
           else
           {
             this.PushNodeNameStart(true, this._index - 1);
             this.DecrementPosition();
           }
           this._state = HtmlDocument.ParseState.Tag;
           continue;
         }
         continue;
       case HtmlDocument.ParseState.Tag:
         if (!this.NewCheck())
         {
           if (HtmlDocument.IsWhiteSpace(this._c))
           {
             this.PushNodeNameEnd(this._index - 1);
             if (this._state == HtmlDocument.ParseState.Tag)
             {
               this._state = HtmlDocument.ParseState.BetweenAttributes;
               continue;
             }
             continue;
           }
           if (this._c == 47)
           {
             this.PushNodeNameEnd(this._index - 1);
             if (this._state == HtmlDocument.ParseState.Tag)
             {
               this._state = HtmlDocument.ParseState.EmptyTag;
               continue;
             }
             continue;
           }
           if (this._c == 62)
           {
             this.PushNodeNameEnd(this._index - 1);
             if (this._state == HtmlDocument.ParseState.Tag)
             {
               if (!this.PushNodeEnd(this._index, false))
               {
                 this._index = this.Text.Length;
                 continue;
               }
               if (this._state == HtmlDocument.ParseState.Tag)
               {
                 this._state = HtmlDocument.ParseState.Text;
                 this.PushNodeStart(HtmlNodeType.Text, this._index);
                 continue;
               }
               continue;
             }
             continue;
           }
           continue;
         }
         continue;
       case HtmlDocument.ParseState.BetweenAttributes:
         if (!this.NewCheck() && !HtmlDocument.IsWhiteSpace(this._c))
         {
           if (this._c == 47 || this._c == 63)
           {
             this._state = HtmlDocument.ParseState.EmptyTag;
//.........这里部分代码省略.........
开发者ID:kirillbeldyaga,项目名称:web_browser,代码行数:101,代码来源:HtmlDocument.cs

示例12: htmlValue

 private string htmlValue(HtmlAttribute node)
 {
     if (node == null)
         return String.Empty;
     else
         return node.Value;
 }
开发者ID:lopeztuparles,项目名称:mp-onlinevideos2,代码行数:7,代码来源:RuutuUtil.cs

示例13: ParsePrefixAttribute

        private void ParsePrefixAttribute(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlAttribute attr, String baseUri, Dictionary<string,Uri> hiddenPrefixes, List<String> inScopePrefixes)
        {
            //Do nothing if the @prefix attribute is empty
            if (attr.Value.Equals(String.Empty)) return;

            StringReader reader = new StringReader(attr.Value);
            char next;
            bool canExit = false;

            do 
            {
                StringBuilder prefixData = new StringBuilder();
                StringBuilder uriData = new StringBuilder();

                //Grab a Prefix - characters up to the next colon
                next = (char)reader.Peek();
                while (next != ':')
                {
                    //Add the Character and discard it
                    prefixData.Append(next);
                    reader.Read();
                    if (reader.Peek() == -1)
                    {
                        this.OnWarning("Aborted parsing a prefix attribute since failed to find a prefix of the form prefix: from the following content: " + prefixData.ToString());
                        return;
                    }
                    else
                    {
                        next = (char)reader.Peek();
                    }
                }

                //Discard the colon
                reader.Read();

                //Discard the whitespace
                next = (char)reader.Peek();
                while (Char.IsWhiteSpace(next))
                {
                    reader.Read();
                    if (reader.Peek() == -1)
                    {
                        this.OnWarning("Aborted parsing a prefix attribute since reached the end of the attribute without finding a URI to go with the prefix '" + prefixData.ToString() + ":'");
                        return;
                    }
                    else
                    {
                        next = (char)reader.Peek();
                    }
                }

                //Grab the URI - characters up to the next whitespace or end of string
                next = (char)reader.Peek();
                while (!Char.IsWhiteSpace(next))
                {
                    uriData.Append(next);
                    reader.Read();
                    if (reader.Peek() == -1)
                    {
                        //End of string so will exit after this
                        canExit = true;
                        break;
                    }
                    else
                    {
                        next = (char)reader.Peek();
                    }
                }

                //Now resolve the URI and apply it
                String uri = Tools.ResolveUri(uriData.ToString(), baseUri);
                if (!(uri.EndsWith("/") || uri.EndsWith("#"))) uri += "#";
                String prefix = prefixData.ToString();
                if (evalContext.NamespaceMap.HasNamespace(prefix))
                {
                    if (hiddenPrefixes == null) hiddenPrefixes = new Dictionary<string, Uri>();
                    hiddenPrefixes.Add(prefix, new Uri(uri));
                }
                evalContext.NamespaceMap.AddNamespace(prefix, new Uri(uri));
                inScopePrefixes.Add(prefix);
            } while (!canExit);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:82,代码来源:RdfAParser.cs

示例14: ParseVocabAttribute

 private void ParseVocabAttribute(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlAttribute attr)
 {
     if (attr.Value.Equals(String.Empty))
     {
         //Reset Local Vocabulary
         evalContext.LocalVocabulary = new TermMappings(context.DefaultVocabulary);
     }
     else
     {
         evalContext.LocalVocabulary.VocabularyUri = attr.Value;
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:12,代码来源:RdfAParser.cs

示例15: Clone

 /// <summary>
 /// Creates a duplicate of this attribute.
 /// </summary>
 /// <returns>The cloned attribute.</returns>
 public HtmlAttribute Clone()
 {
     var att = new HtmlAttribute(_ownerdocument) {
         Name = Name,
         Value = Value
     };
     return att;
 }
开发者ID:moby41,项目名称:HtmlAgilityPack,代码行数:12,代码来源:HtmlAttribute.cs


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