首页 \ 问答 \ xPath:选择一系列兄弟节点,直到特定的兄弟节点(xPath: select a range of sibling nodes until a specific sibling node)

xPath:选择一系列兄弟节点,直到特定的兄弟节点(xPath: select a range of sibling nodes until a specific sibling node)

我有以下Lis

<ul>
    //1st subcategory with 4 sub categories        
    <li class="supercategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>

    //2nd subcategory with 3 sub categories 
    <li class="supercategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>

    //3d subcategory with 1 sub category
    <li class="supercategory"></li>
      <li class="subcategory"></li>
</ul>

我一直试图获得所有超级类别之后的“2级”。 因此,对于第一个超类别,xpath匹配将是4个子类别sibling lis和第二个超类别,xpath将返回3 lis等等。

我尝试了几件事情,但简单的开始会是这样的:

//li[@class="supercategory"][position()=2]/following-sibling::li[@class ="subcategory"]

我试图在第二个超类别之后获得3子类别lis ,但显然这将返回所有具有类子类别的lis

因此,我想知道是否有一个更适合解决这个问题的谓词。 特别是在这种情况下,子类别是它们的超类别的兄弟节点。

为了方便起见,我一直在测试这里: https//www.freeformatter.com/xpath-tester.html

提前致谢。


I have the following Lis:

<ul>
    //1st subcategory with 4 sub categories        
    <li class="supercategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>

    //2nd subcategory with 3 sub categories 
    <li class="supercategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>
      <li class="subcategory"></li>

    //3d subcategory with 1 sub category
    <li class="supercategory"></li>
      <li class="subcategory"></li>
</ul>

I have been trying to get all the "level-2"s that come after each super category. So for the 1st supercategory the xpath match would be the 4 subcategories sibling lis and the 2nd supercategory the xpath will return 3 lis and so on.

I have tried several things but a simplistic start would be something like:

//li[@class="supercategory"][position()=2]/following-sibling::li[@class ="subcategory"]

I am trying to get the 3 subcategory lis after the 2nd supercategory but obviously this will return all lis with classes subcategory.

Thus, I am wondering if there is a predicate that would be more suited to solve this problem. Especially that in this scenario the subcategories are sibling nodes with their supercategories.

For convenience I have been testing this here: https://www.freeformatter.com/xpath-tester.html

Thanks in advance.


原文:https://stackoverflow.com/questions/45676520
更新时间:2022-07-09 14:07

最满意答案

下面的截图过程非常简单。 添加您的RDS主机字符串,RDS用户名和添加密码的相关信息,方法是单击“Store In Keychain”并确保您的机器IP地址已添加到AWS RDS实例的安全组。

在这里输入图像描述


the process is very simple check below screenshot. Add the relevant information your RDS Host String, RDS Username and Add the password by clicking on "Store In Keychain" and make sure your machine IP address is added to the Security Group of the AWS RDS instance.

enter image description here

相关问答

更多
  • 下面的截图过程非常简单。 添加您的RDS主机字符串,RDS用户名和添加密码的相关信息,方法是单击“Store In Keychain”并确保您的机器IP地址已添加到AWS RDS实例的安全组。 the process is very simple check below screenshot. Add the relevant information your RDS Host String, RDS Username and Add the password by clicking on "Store I ...
  • 有几件事需要检查 安全组(你已经做到了,看起来不错) 子网是公开的吗? 即它有一个路由表,其中包含一个说明0.0.0.0/0 DST Internet Gateway的规则 Internet Gateway已连接到您的VPC 另外,我强烈建议不要在互联网上公开您的数据库。 在理想情况下,您的数据库必须只有一个私有IP地址,并且只能从您的应用服务器获得。 如果您确实需要能够从Internet访问数据库,则应将安全组限制为/ 32 IP地址 A couple of things to check Securit ...
  • 您指的防火墙是安全组。 您是否可以选择您的RDS实例,单击显示详细信息并确保连接到它的安全组在端口3306上具有源0.0.0.0/0的入站规则(最佳做法是仅允许从IP范围访问您将实际上从它访问它? 如果可以,请单击为RDS实例创建的VPC(仍在RDS详细信息页面上),在VPC的页面上,在左侧菜单上有一个安全组选项。 应该有一个“从RDS管理控制台创建”规则。 检查是否还配置为允许访问端口3306。 如果允许这些,使用mySQL Workbench的连接应该有效。 如果没有,可能是连接中的凭据。 The fi ...
  • 以上问题是由于您的EC2实例无法访问您的MYSQL RDS。 请添加访问权限,您的应用将开始工作。 请遵循本指南http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithSecurityGroups.html#USER_WorkingWithSecurityGroups.AuthorizingEC2 The above issue is due to your EC2 instance is not having access ...
  • 新数据库实例连接失败的两个常见原因是: 该数据库实例是使用安全组创建的,该组不授权来自设备或Amazon应用程序或实用程序运行的Amazon EC2实例的连接。 如果数据库实例是在VPC中创建的,则它必须具有授权连接的VPC安全组。 如果数据库实例是在VPC之外创建的,则它必须具有授权连接的数据库安全组。 数据库实例是使用默认端口3306创建的,并且您的公司具有防火墙规则,阻止与公司网络中的设备连接到该端口。 要修复此故障,请使用其他端口重新创建实例。 您可以在连接到Amazon RDS MySQL数据库实 ...
  • 如果您查看mysqli_connect的文档,则第一个参数应该是主机名,如果您要指定非标准端口,则有可选参数。 因此,如果您从DB_SERVER值中删除:3306,它应该可以工作。 If you look at the documentation for mysqli_connect, the first parameter should be the hostname, and there are optional parameters if you want to specify a non-stand ...
  • 默认情况下,只能从VPC中访问RDS实例。 如果要从VPC外部访问它,则需要在RDS实例上启用“可公开访问”标志。 By default an RDS instance is only accessible from within your VPC. If you want to access it from outside your VPC you need to enable the "Publicly Accessible" flag on the RDS instance.
  • RDS是一种管理解决方案。 这意味着,AWS员工将负责: 补丁 备份 保养 确保它是活着的 将数据库托管在第二个EC2实例中意味着: 你必须管理上述所有内容 使用LAMP堆栈和共同托管Apache和MySQL是最便宜的,但是: 你必须管理上述所有内容 您可能在暴露给互联网的实例上托管数据库 也就是说,如果您计划托管一个不仅仅是个人网站/博客/实验的生产网站/服务,您可能需要在不同的实例中托管网络服务器和数据库。 采摘RDS不是一件令人头疼的事情。 对于那些不重要的事情,LAMP堆栈更有意义。 可扩展性较差, ...
  • 找到答案了! 显然问题在于安全组。 更新了安全组以接受来自任何IP的TCP端口0-65535的连接,现在问题已解决! Found the answer! Apparently the problem was with the security groups. Updated the security groups to accept connections from TCP port 0-65535 from any IP and now the problem is solved!
  • 假设您没有修改NACL,请检查RDS是否允许从服务器的IP连接到端口3306。 如果要打开它,它应该是0.0.0.0/0。 此外,请确保“公开可访问”设置为“是”。 Assuming you did not modify NACLs, check that RDS allows connection to port 3306 from your server's IP. If you want to open it for all it should be 0.0.0.0/0. Also, make sur ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)