Forum Discussion

Fabiolus's avatar
Fabiolus
Occasional Contributor
16 years ago

Removing Nodes when field is blank

Good day,


I just got my license for the pro version 3.0.1 and did my first script and was trying to add more to it but got stuck. I was wondering if I was in the right direction and if assistance was available. Thank You very much for your help

Bassically my script reads a spreadsheet row by row to send specific values to the WSDL. Some rows are blank and others have data and I was trying to create a groovy script that would remove a specific node when the cell for a specific column in the spreadsheet was blank because it was failing my test.


The script as follow

import java.text.*
import java.io.*;
import java.util.*;

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )


//variable length to hold value of the field "LenghtInCm" found in the spreadsheet

def Length = context.expand( '${Read Spreadsheet#LengthInCm(if empty, remove node)}' )


def holder = groovyUtils.getXmlHolder("getDistrOrderRate#Request")


// Length Iff statement to remove node when field in spreadsheet is blank

if ((Length.equals("") == true) || (Length.equals(" ") == true))
   {
         holder.removeDomNodes("//ord1:LengthInCm");
   }

//keep node if value found in the column "LengthInCm" found in spreadsheet.
            else
{
holder.setNodeValue("//ord1:LengthInCm", Length);
}//if-else(Length)

3 Replies

  • Hello,

    If already have pro version you should use data source test step. It will be much easier to read spreadsheet and remove rows with blank columns.
    Also, there is a pro forum, where you should send your posts.

    Let me know does this helps,
    robert
  • Fabiolus's avatar
    Fabiolus
    Occasional Contributor
    Hello,

    Thank You, how does one get to the forum for the Pro users?


    Cheers
    Fab