Groovy'的完整语法是什么;s GPath表达式?

Groovy'的完整语法是什么;s GPath表达式?,groovy,Groovy,在Groovy中解析RSS提要时,我发现了一个使用通配符的GPath示例: def text = """ <data> <common-tables> <table name="address"/> <table name="phone"/> </common-tables> <special-tables> <table name="person"/>

在Groovy中解析RSS提要时,我发现了一个使用通配符的GPath示例:

def text = """ 
<data> 
   <common-tables> 
    <table name="address"/> 
    <table name="phone"/> 
  </common-tables> 

  <special-tables> 
    <table name="person"/> 
  </special-tables> 

  <other-tables> 
    <table name="business"/> 
  </other-tables> 
</data> 
""" 

def xml = new XmlParser().parse(new ByteArrayInputStream(text.getBytes())) 
def tables = xml.'**'.table.findAll{ it.parent().name() == 
"special-tables" || it.parent().name
def text=”“”
""" 
def xml=new XmlParser().parse(new ByteArrayInputStream(text.getBytes()))
def tables=xml.'**'.table.findAll{it.parent().name()=
“特殊表”| | it.parent().name
(来自)

“spread dot”操作符的用法看起来很有趣。我在Groovy网站、书籍等上找不到任何关于这个的参考


这是如何工作的,更重要的是,您是如何发现这一点的?是否存在指向GPath“Rosetta Stone”的XPath?

好的,像往常一样,查找信息的最佳位置是Groovy源代码本身。
解析的结果是groovy.util.slurpersupport.GPathResult对象

如果查看源代码(纯java文件),您将看到getProperty(string)方法具有以下特殊运算符:

  • “.”返回父级
  • “*”返回所有子项
  • “**”作为深度优先循环
  • 用于访问属性的“@”
  • 普通节点访问器

仅此而已,目前还没有其他神奇的关键字。

所有这些字符串都被视为属性。它们实际上都不是运算符


这些电话是通过专门检查gizmo答案中列出的接线员的线路发送的。

太好了,谢谢!我试过查看来源,但找不到要查找的位置。