Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:24:39+00:00 2026-06-08T08:24:39+00:00

I have the following xml code: <soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/> <soapenv:Body> <cms:RelatedConfigurationItemList xmlns:cms=some namespace> <ConfigurationItem> <name>data</name>

  • 0

I have the following xml code:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <cms:RelatedConfigurationItemList xmlns:cms="some namespace">
         <ConfigurationItem>
            <name>data</name>
            <id>data</id>
            <type>data</type>
            <relationship>IS CHILD OF</relationship>
            <ConfigurationItemList>
               <ConfigurationItem>
                  <name>data</name>
                  <id>data</id>
                  <type>data</type>
                  <relationship>IS CHILD OF</relationship>
                  <ConfigurationItemList/>
               </ConfigurationItem>
               <ConfigurationItem>
                  <name>data</name>
                  <id>data</id>
                  <type>data</type>
                  <relationship>IS CHILD OF</relationship>
                  <ConfigurationItemList/>
               </ConfigurationItem>
            </ConfigurationItemList>
         </ConfigurationItem>
     <ConfigurationItem>
            <name>other data</name>
            <id>other data</id>
            <type>other data</type>
            <relationship>IS CHILD OF</relationship>
            <ConfigurationItemList>
               <ConfigurationItem>
                  <name>other data</name>
                  <id>other data</id>
                  <type>other data</type>
                  <relationship>IS CHILD OF</relationship>
                  <ConfigurationItemList/>
               </ConfigurationItem>
               <ConfigurationItem>
                  <name>other data</name>
                  <id>other data</id>
                  <type>other data</type>
                  <relationship>IS CHILD OF</relationship>
                  <ConfigurationItemList/>
               </ConfigurationItem>
            </ConfigurationItemList>
         </ConfigurationItem>
      </cms:RelatedConfigurationItemList>
   </soapenv:Body>
</soapenv:Envelope>

That I want to validate in Groovy using the following psuedo-code:

def request = testRunner.testCase.getTestStepByName( "relationship_request" )
def resp = new File('H://test_xml.xml')
def cms_ns = new groovy.xml.Namespace("namespace for cms",'cms')
def soap_ns = new groovy.xml.Namespace("http://schemas.xmlsoap.org/soap/envelope/",'soapenv')
def root = new XmlSlurper().parse(resp)


def config_item = root[soap_ns.Envelope][soap_ns.Body][cms_ns.RelatedConfigurationItemList][ConfigurationItem]

config_item.each{
    it.name.each{
        it == corresponding value in db?
        else
        die
    }
}

But I can’t seem to get the syntax, logic right for trying to validate values defined (such as name) against a database response. If the config_item declaration is correct, then maybe I have a poor understanding of Groovy closures. Also, I’m not sure if XML slurper or parser is more appropiate and can’t quite nail down what exactly the differences are. Hope this is an adequate description of the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:24:40+00:00Added an answer on June 8, 2026 at 8:24 am

    XmlSlurper works on on-demand basis and is less memory intensive. When you need to access many nodes of the xml, you generally use an XmlParser. Or in case if you just want to read one or two nodes of an xml, you use Slurper.

    This example should help you understand how XMLParser works.

    In your case the config item declaration and namespace usage is syntactically correct but it might be ideal to use XmlParser as you might be validating many or all components of your xml. You might be getting confused regarding access of elements using closures. Here is your example without namespaces to help you understand.

       xml = '''<Envelope>
       <Body>
          <RelatedConfigurationItemList>
             <ConfigurationItem>
                <name>Top level name1</name>
                <id>Top level id1</id>
                <type>Top level type1</type>
                <relationship>IS CHILD OF</relationship>
                <ConfigurationItemList>
                   <ConfigurationItem>
                      <name>data1</name>
                      <id>data1</id>
                      <type>data1</type>
                      <relationship>IS CHILD OF</relationship>
                      <ConfigurationItemList/>
                   </ConfigurationItem>
                   <ConfigurationItem>
                      <name>data2</name>
                      <id>data2</id>
                      <type>data2</type>
                      <relationship>IS CHILD OF</relationship>
                      <ConfigurationItemList/>
                   </ConfigurationItem>
                </ConfigurationItemList>
             </ConfigurationItem>
         <ConfigurationItem>
                <name>Top level name2</name>
                <id>Top level id2</id>
                <type>Top level type2</type>
                <relationship>IS CHILD OF</relationship>
                <ConfigurationItemList>
                   <ConfigurationItem>
                      <name>other data</name>
                      <id>other data</id>
                      <type>other data</type>
                      <relationship>IS CHILD OF</relationship>
                      <ConfigurationItemList/>
                   </ConfigurationItem>
                   <ConfigurationItem>
                      <name>other data</name>
                      <id>other data</id>
                      <type>other data</type>
                      <relationship>IS CHILD OF</relationship>
                      <ConfigurationItemList/>
                   </ConfigurationItem>
                </ConfigurationItemList>
             </ConfigurationItem>
          </RelatedConfigurationItemList>
       </Body>
    </Envelope>'''
    
    
    
    def Envelope = new XmlParser().parseText(xml)
    
    //For accessing top level top level Configuration Item
    Envelope.Body.RelatedConfigurationItemList.ConfigurationItem.each{
     //Put your check conditions here.. == or any other
     assert it.name.text().contains("Top level name")
     assert it.id.text().contains("Top level id")
     assert it.type.text().contains("Top level type")
     //Inner children configuration items
     it.ConfigurationItemList.ConfigurationItem.each{
         assert it.name.text().contains("data")
         assert it.id.text().contains("data")
         assert it.type.text().contains("data")
     }       
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following xml; <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'> <env:Header> <mm7:TransactionID xmlns:mm7='http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4' env:mustUnderstand='1'>6797324d</mm7:TransactionID> </env:Header> <env:Body> <DeliveryReportReq
I have the following .xsd code: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema id=MyDataSet> <xs:element name=Row>
I have the following XML document <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:issues='http://schemas.google.com/projecthosting/issues/2009' gd:etag='W/DEAERH47eCl7ImA9WhZTFEQ.'><id>http://code.google.com/feeds/issues/p/chromium/issues/full/921</id><published>2008-09-03T22:51:22.000Z</published><updated>2011-03-19T01:05:05.000Z</updated><title>Incorrect rendering</title><content
I have the following Xml structure: <sitemapindex xmlns=http://www.sitemaps.org/schemas/sitemap/0.9> <sitemap> <loc>http://www.example.com/</loc> <lastmod>2011-11-27T08:34:46+00:00</lastmod> </sitemap> <sitemap> <loc>http://www.example.com/123</loc>
I have the following XML code for my cells (search_cell.xml) : <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have the following shape XML: <?xml version=1.0 encoding=utf-8?> <shape xmlns:a=http://schemas.android.com/apk/res/android a:shape=ring a:innerRadiusRatio=3 a:thicknessRatio=8
I have the following code: $body = <SOAP-ENV:Envelope>.$data.</SOAP-ENV:Envelope>; $ch = curl_init($FD_Add); curl_setopt($ch, CURLOPT_POST, 1);
I have the following code: $page=3; $i=1; while($i<=$pages) { $urls .= '.http://twitter.com/favorites.xml?page= . $i
I have an SOAP response that looks similar to this: <?xml version=1.0 encoding=UTF-8?> <soapenv:Envelope
I have the following XML code: <root> <options> <companies> <company url=http://www.brown.com>Brown LLC</company> <company url=http://www.yellow.com>Yellow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.