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
最满意答案
相关问答
更多-
下面的截图过程非常简单。 添加您的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 ...
-
如何连接到MySQL Workbench上的Amazon Web Service RDS?(How to connect to Amazon Web Service RDS on MySQL Workbench?)[2023-03-15]
新数据库实例连接失败的两个常见原因是: 该数据库实例是使用安全组创建的,该组不授权来自设备或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.
-
我为什么要使用AWS RDS?(Why should I use AWS RDS?)[2023-06-10]
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 ...