« Return to Thread: Q: Avoiding XPath - using GPath

Q: Avoiding XPath - using GPath

by grkuntzmd :: Rate this Message:

Reply to Author | View in Thread

I played with this yesterday for about 1/2 hour, but could not come up with the right GPATH code

I have an XML document with the following structure:

<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>

I was trying to come up with GPath code that lets me get the name attributes from the table elements, but only if they are under the "common-tables" or "special-tables", excluding those under the "other-tables".

I tried both XmlParser and XmlSlurper, and all combinations of findAll that I could think of.

I am a Groovy-Newbie (I should trademark that :-)) and searched the Groovy home, as well as all of my Groovy books.

Any ideas?

G. Ralph Kuntz, MD

 « Return to Thread: Q: Avoiding XPath - using GPath