Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2115

text() method on NodeChild with XmlSlurper returns composite. Need just local text.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.3.0-beta-2
    • XML Processing
    • None
    • windows xp on jdk 1.4.2

    Description

      I am trying to use XmlSlurper to process and xml with nested elements with text in them. I need to get the text from just one level at a time but the text() method returns all text for all childrend and I can't see anything that would bring back just the local.

      Here is a sample from the console:

      groovy> def model = new XmlSlurper().parseText('<aModel><aParent name="bubba">text<aChild>child text</aChild></aParent></aModel>')

      groovy> model.aParent[0].text()

      groovy>

      groovy>

      Result: "textchild text"

      Attachments

        Activity

          People

            paulk Paul King
            ken.sayers Ken Sayers
            Votes:
            8 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: