本文整理汇总了C#中HtmlAgilityPack.HtmlNode.GetId方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNode.GetId方法的具体用法?C# HtmlNode.GetId怎么用?C# HtmlNode.GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlAgilityPack.HtmlNode
的用法示例。
在下文中一共展示了HtmlNode.GetId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceChild
/// <summary>
/// Replaces the child node oldChild with newChild node.
/// </summary>
/// <param name="newChild">The new node to put in the child list.</param>
/// <param name="oldChild">The node being replaced in the list.</param>
/// <returns>The node replaced.</returns>
public HtmlNode ReplaceChild(HtmlNode newChild, HtmlNode oldChild)
{
if (newChild == null)
{
return RemoveChild(oldChild);
}
if (oldChild == null)
{
return AppendChild(newChild);
}
int index = -1;
if (_childnodes != null)
{
index = _childnodes[oldChild];
}
if (index == -1)
{
throw new ArgumentException(HtmlDocument.HtmlExceptionRefNotChild);
}
if (_childnodes != null) _childnodes.Replace(index, newChild);
_ownerdocument.SetIdForNode(null, oldChild.GetId());
_ownerdocument.SetIdForNode(newChild, newChild.GetId());
_outerchanged = true;
_innerchanged = true;
return newChild;
}
示例2: AppendChild
/// <summary>
/// Adds the specified node to the end of the list of children of this node.
/// </summary>
/// <param name="newChild">The node to add. May not be null.</param>
/// <returns>The node added.</returns>
public HtmlNode AppendChild(HtmlNode newChild)
{
if (newChild == null)
{
throw new ArgumentNullException("newChild");
}
ChildNodes.Append(newChild);
_ownerdocument.SetIdForNode(newChild, newChild.GetId());
_outerchanged = true;
_innerchanged = true;
return newChild;
}
示例3: InsertBefore
/// <summary>
/// Inserts the specified node immediately before the specified reference node.
/// </summary>
/// <param name="newChild">The node to insert. May not be <c>null</c>.</param>
/// <param name="refChild">The node that is the reference node. The newChild is placed before this node.</param>
/// <returns>The node being inserted.</returns>
public HtmlNode InsertBefore(HtmlNode newChild, HtmlNode refChild)
{
if (newChild == null)
{
throw new ArgumentNullException("newChild");
}
if (refChild == null)
{
return AppendChild(newChild);
}
if (newChild == refChild)
{
return newChild;
}
int index = -1;
if (_childnodes != null)
{
index = _childnodes[refChild];
}
if (index == -1)
{
throw new ArgumentException(HtmlDocument.HtmlExceptionRefNotChild);
}
if (_childnodes != null) _childnodes.Insert(index, newChild);
_ownerdocument.SetIdForNode(newChild, newChild.GetId());
_outerchanged = true;
_innerchanged = true;
return newChild;
}
示例4: ReplaceChild
/// <summary>
/// Replaces the child node oldChild with newChild node.
///
/// </summary>
/// <param name="newChild">The new node to put in the child list.</param><param name="oldChild">The node being replaced in the list.</param>
/// <returns>
/// The node replaced.
/// </returns>
public HtmlNode ReplaceChild(HtmlNode newChild, HtmlNode oldChild)
{
if (newChild == null)
return this.RemoveChild(oldChild);
if (oldChild == null)
return this.AppendChild(newChild);
int index = -1;
if (this._childnodes != null)
index = this._childnodes[oldChild];
if (index == -1)
throw new ArgumentException(HtmlDocument.HtmlExceptionRefNotChild);
if (this._childnodes != null)
this._childnodes.Replace(index, newChild);
this._ownerdocument.SetIdForNode((HtmlNode) null, oldChild.GetId());
this._ownerdocument.SetIdForNode(newChild, newChild.GetId());
this._outerchanged = true;
this._innerchanged = true;
return newChild;
}
示例5: PrependChild
/// <summary>
/// Adds the specified node to the beginning of the list of children of this node.
///
/// </summary>
/// <param name="newChild">The node to add. May not be <c>null</c>.</param>
/// <returns>
/// The node added.
/// </returns>
public HtmlNode PrependChild(HtmlNode newChild)
{
if (newChild == null)
throw new ArgumentNullException("newChild");
this.ChildNodes.Prepend(newChild);
this._ownerdocument.SetIdForNode(newChild, newChild.GetId());
this._outerchanged = true;
this._innerchanged = true;
return newChild;
}
示例6: InsertAfter
/// <summary>
/// Inserts the specified node immediately after the specified reference node.
///
/// </summary>
/// <param name="newChild">The node to insert. May not be <c>null</c>.</param><param name="refChild">The node that is the reference node. The newNode is placed after the refNode.</param>
/// <returns>
/// The node being inserted.
/// </returns>
public HtmlNode InsertAfter(HtmlNode newChild, HtmlNode refChild)
{
if (newChild == null)
throw new ArgumentNullException("newChild");
if (refChild == null)
return this.PrependChild(newChild);
if (newChild == refChild)
return newChild;
int num = -1;
if (this._childnodes != null)
num = this._childnodes[refChild];
if (num == -1)
throw new ArgumentException(HtmlDocument.HtmlExceptionRefNotChild);
if (this._childnodes != null)
this._childnodes.Insert(num + 1, newChild);
this._ownerdocument.SetIdForNode(newChild, newChild.GetId());
this._outerchanged = true;
this._innerchanged = true;
return newChild;
}