• HtmlAgilityPack 使用


    或、无属性、属性个数、属性值:

    var preceding_siblings = node.SelectNodes("preceding-sibling::input| preceding-sibling::button[count(@role)>0] | preceding-sibling::div[not(@*)]"); 

    var ancestors = node.SelectNodes("ancestor::div | ancestor:div[@level='primary'] | ancestor::div/ul");

    以全小写查找:

    var content_venue_nodes = this.GetNodes("//div//text()[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'hello world')]");

    ......

    轴名称

    结果

    ancestor

    选取当前节点的所有先辈(父、祖父等)

    ancestor-or-self

    选取当前节点的所有先辈(父、祖父等)以及当前节点本身

    attribute

    选取当前节点的所有属性

    child

    选取当前节点的所有子元素。

    descendant

    选取当前节点的所有后代元素(子、孙等)。

    descendant-or-self

    选取当前节点的所有后代元素(子、孙等)以及当前节点本身。

    following

    选取文档中当前节点的结束标签之后的所有节点。

    namespace

    选取当前节点的所有命名空间节点

    parent

    选取当前节点的父节点。

    preceding

    直到所有这个节点的父辈节点,顺序选择每个父辈节点前的所有同级节点

    preceding-sibling

    选取当前节点之前的所有同级节点。

    self

    选取当前节点。

  • 相关阅读:
    python学习之调试:
    python学习之调试 错误捕捉及处理
    python之面向对象
    python学习之模块:
    python学习之内部函数:
    python学习之高级特性:
    python学习之结构语句
    python学习之列表元组,字典
    getopt使用例子
    找到系统盘被打满文件
  • 原文地址:https://www.cnblogs.com/yipeng-yu/p/7278299.html
Copyright © 2020-2023  润新知