如何在xpath中的单个节点内查找重复属性的数量? [英] How to find the number of duplicate attributes within a single node in xpath?

查看:30
本文介绍了如何在xpath中的单个节点内查找重复属性的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<Restaurant>
   <firstFloor type="chinese" price="High" type="Indian">
   <firstFloor type="chinese" price="High">
</Restaurant>

我正在尝试使用 xpath 1.0 在单个节点内查找重复属性的数量.

I am trying to find the number of duplicate attributes inside a single node using xpath 1.0.

谁能告诉一个方法来发现 type 在第一个 firstFloor 节点中被分配了两次?现有解决方案没有提供在同一节点内查找重复属性的解决方案(比较兄弟节点)?

Can anyone tell a method to find that type has been assigned two times in the first firstFloor node? Existing solutions does not provide solution to find the duplicate attributes within the same node (Compares sibling nodes)?

我期待 xpath 1.0 的答案,但 xpath 2.0 的答案也是可以接受的.

I am expecting for a xpath 1.0 answer however xpath 2.0 answer is also acceptable.

提前致谢.

推荐答案

没有 XML 工具(包括 XPath)可以帮助您处理数据,因为您的数据不是 XML.

  • XML 不允许在单个属性上具有相同名称的两个属性元素.
  • XML 要求所有元素都是自闭合的或具有结束标记.

另见:

  1. 如何解析无效(错误/格式不正确)的 XML?
  2. Well-formed的解释

这篇关于如何在xpath中的单个节点内查找重复属性的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆