Improving what I extract for my xml tag

James McMahon <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CAEqJCe0e1Np1ZFCQPb1RWom6Qc6WE6r8n_2aPEkMP8jYN3oE-g@mail.gmail.com>
Hello. I am developing a Groovy script to work through all the tags in an
incoming text representation of an xml file. I've read my xml from the
content of a NiFi flowfile, like so:

session.read(ff, {inputStream ->
          text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
          def xml = new XmlParser().parseText(text)

Later in my code I iterate through the xml to find all the values
associated with that tag. Ultimately I will build a unique sorted list,
tagValues.

This is the code section that I have working so far:

incomingTagsMap.each {
               tagValues.clear()
              * xml.'**'.each { itt ->*
                    log.warn('Found this tag: {}, with this value: {}',
itt.name(), itt.text())
                    // If itt.text() is not on tagValues list, add it...
                    if ( !tagValues.contains(itt.text()) ) {
tagValues.add(itt.text()) }
                    log.warn('Length of tagValues list : {}',
tagValues.size())
               }
               log.warn('Tag {} has values: {}', ["$it.key",
tagValues.toListString()] as Object[])
          }

$it.key comes from an outer iterative loop.

Where I am failing:
I was hoping someone could help me tune this because in cases like this....
     <property name="User Group
Provider">file-user-group-provider</property>
...I only get *property *as the tag. What I really want to identify as my
tag is *User Group Provider*  .

I've been unable to find any examples. Can anyone show me how to accomplish
this?

Thanks very much in advance.
Cheers,
Jim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.