gpt4 book ai didi

debugging - 通过 XPath 选择除某些属性之外的所有属性

转载 作者:行者123 更新时间:2023-12-03 16:54:07 25 4
gpt4 key购买 nike

我想选择 id 以外的所有属性节点和 class属性。我在这里做错了什么?

/x:html/x:body/x:*/@*[(local-name() != 'id') and (local-name() != 'class')]

最佳答案

使用 local-name()谓词中的方法过滤掉idclass .例如,在浏览器控制台中的 stackoverflow 页面上运行它:

$x("//@*[local-name() != 'id' and local-name() != 'class']")

及其相反的确认:
$x("//@*[local-name() = 'id' or local-name() = 'class']")

引用文献
  • Things to Know and Avoid When Querying XML Documents with XPath
  • XML Namespaces and How They Affect XPath and XSLT
  • How XQuery extends XPath
  • 关于debugging - 通过 XPath 选择除某些属性之外的所有属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24089782/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com