本文整理汇总了C#中HtmlAgilityPack.HtmlAttribute类的典型用法代码示例。如果您正苦于以下问题:C# HtmlAttribute类的具体用法?C# HtmlAttribute怎么用?C# HtmlAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlAttribute类属于HtmlAgilityPack命名空间,在下文中一共展示了HtmlAttribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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("2", "\"");
value = value.Replace("<", "<");
value = value.Replace(">", ">");
value = value.Replace("&", "&");
value = value.Replace("'", "'");
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
示例16: ProcessAttrubute
private void ProcessAttrubute(HtmlAttribute imgSrcAttribute)
{
var newSrcValue = ProcessUrl(imgSrcAttribute.Value);
imgSrcAttribute.Value = newSrcValue;
}
开发者ID:Barada,项目名称:webcrawler,代码行数:5,代码来源:BasePageElementProcessor.cs
示例17: ExtractMake
private static string ExtractMake(HtmlAttribute htmlAttribute)
{
if (htmlAttribute != null)
return htmlAttribute.Value.Replace(@"/usedcar/", string.Empty).Replace(@"/index.html", string.Empty).ToUpper();
return string.Empty;
}
开发者ID:badokun,项目名称:vehicleanalysis,代码行数:6,代码来源:GooNetArgumentBuilder.cs
示例18: IsStaticResource
private bool IsStaticResource(HtmlNode node, HtmlAttribute attr)
{
var nodeName = node.Name.ToLower();
if (nodeName == "link" || nodeName == "script" || nodeName == "img")
{
return true;
}
var extension = Path.GetExtension(attr.Value).ToLower();
if (extension == ".js" || extension == ".css" || extension == ".png" || extension == ".jpg" || extension == ".jpeg" || extension == ".ico" || extension == ".gif")
{
return true;
}
return false;
}
开发者ID:rongzhi-Kooboo,项目名称:CMS,代码行数:16,代码来源:IProxyHtmlFixer.cs
示例19: IsStaticResource
private bool IsStaticResource(HtmlNode node, HtmlAttribute attr)
{
var nodeName = node.Name.ToLower();
if (nodeName == "link" || nodeName == "script" || nodeName == "img")
{
return true;
}
var attValue = (attr.Value ?? "").ToLower();
if (attr.Value.StartsWith("#") || attr.Value.StartsWith("javascript:"))
{
return true;
}
if (attValue.EndsWith(".js") || attValue.EndsWith(".css") || attValue.EndsWith(".png") || attValue.EndsWith(".jpg")
|| attValue.EndsWith(".jpeg") || attValue.EndsWith(".ico") || attValue.EndsWith(".gif"))
{
return true;
}
return false;
}
开发者ID:eyouyou,项目名称:Bsc,代码行数:21,代码来源:IProxyHtmlParser.cs
示例20: ParseProfileAttribute
private bool ParseProfileAttribute(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlAttribute attr)
{
String[] profiles;
if (attr.Value.Contains(" "))
{
profiles = attr.Value.Split(' ');
}
else
{
profiles = new String[] { attr.Value };
}
String prefixQuery = "PREFIX rdfa: <" + RdfANamespace + "> SELECT SAMPLE(?prefix) AS ?NamespacePrefix SAMPLE(?uri) AS ?NamespaceURI WHERE { ?s rdfa:prefix ?prefix ; rdfa:uri ?uri } GROUP BY ?s HAVING (COUNT(?prefix) = 1 && COUNT(?uri) = 1)";
String termQuery = "PREFIX rdfa: <" + RdfANamespace + "> SELECT SAMPLE(?term) AS ?Term SAMPLE(?uri) AS ?URI WHERE {?s rdfa:term ?term ; rdfa:uri ?uri } GROUP BY ?s HAVING (COUNT(?term) = 1 && COUNT(?uri) = 1)";
foreach (String profile in profiles)
{
try
{
Graph g = new Graph();
if (profile.Equals(XHtmlVocabNamespace) || profile.Equals(XHtmlVocabNamespace.Substring(0, XHtmlVocabNamespace.Length-1)))
{
//XHTML Vocabulary is a fixed vocabulary
evalContext.LocalVocabulary.Merge(new XHtmlRdfAVocabulary());
}
else
{
try
{
UriLoader.Load(g, new Uri(profile));
}
catch
{
//If we fail then we return false which indicates that the DOM subtree is ignored
this.OnWarning("Unable to retrieve a Profile document which the library could parse from the URI '" + profile + "'");
return false;
}
//Namespace Mappings
Object results = g.ExecuteQuery(prefixQuery);
if (results is SparqlResultSet)
{
SparqlResultSet rset = (SparqlResultSet)results;
foreach (SparqlResult r in rset.Results)
{
INode prefixNode = r["NamespacePrefix"];
INode nsNode = r["NamespaceURI"];
if (prefixNode.NodeType == NodeType.Literal && nsNode.NodeType == NodeType.Literal)
{
String prefix = ((ILiteralNode)prefixNode).Value.ToLower();
String ns = ((ILiteralNode)nsNode).Value;
evalContext.LocalVocabulary.AddNamespace(prefix, ns);
}
}
}
//Term Mappings
results = g.ExecuteQuery(termQuery);
if (results is SparqlResultSet)
{
SparqlResultSet rset = (SparqlResultSet)results;
foreach (SparqlResult r in rset.Results)
{
INode termNode = r["Term"];
INode uriNode = r["URI"];
if (termNode.NodeType == NodeType.Literal && uriNode.NodeType == NodeType.Literal)
{
String term = ((ILiteralNode)termNode).Value;
String uri = ((ILiteralNode)uriNode).Value;
evalContext.LocalVocabulary.AddTerm(term, uri);
}
}
}
}
}
catch
{
//Ignore errors and continue processing
this.OnWarning("Ignoring the value '" + profile + "' since this is not a valid URI or a profile document was not successfully retrieved and parsed from this URI");
return false;
}
}
return true;
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:86,代码来源:RdfAParser.cs
注:本文中的HtmlAgilityPack.HtmlAttribute类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论