Forum Discussion
Similarly if I change the xpath to -
String xPath = "//*:Response/*:Barometer/*:OneDay"
then -
log.info responseNodes.getLength() = 19 ?
I would like to know how is the figure 19 is being calculated and is the scrpt i am using is correct .
Hi Skelkar,
I read your script and I think, because you have given getchildnodes() in the holder, it is calculating child nodes as well.
Try with out giving getchildnodes() and check if you get the expected result.
Cheers,
Dhivya
- skelkar10 years agoContributor
I have to use the holder to access barometer and its child nodes.
Script is correct and working fine I just wanted to understand why the count is 13.
How soap ui is calculating the lenth as 13 if some one can answer and clarify that would be gr8 help.
- nmrao10 years agoChampion Level 3
Somehow, the script you posted not working for when tried, running into compilation issue.
And this how i could assert.
Note that you may directly pass the response instead of inline xml data, so you may replace the value for response if needed.
import com.eviware.soapui.support.XmlHolder def response=''' <Response> <Barometer> <OneDay> <MLCR>2</MLCR> <MLGR>2</MLGR> <MLVL>2</MLVL> <MMCR>2</MMCR> <MMGR>2</MMGR> <MMVL>2</MMVL> <MSCR>2</MSCR> <MSGR>2</MSGR> <MSVL>2</MSVL> </OneDay> <OneMonth> <MLCRT>-2</MLCRT> <MLGRT>-1</MLGRT> <MLVLT>-3</MLVLT> <MMCRT>-1</MMCRT> <MMGRT>-1</MMGRT> <MMVLT>-2</MMVLT> <MSCRT>-2</MSCRT> <MSGRT>-1</MSGRT> <MSVLT>-2</MSVLT> </OneMonth> <OneWeek> <MLCRT>-3</MLCRT> <MLGRT>-2</MLGRT> <MLVLT>-3</MLVLT> <MMCRT>-2</MMCRT> <MMGRT>-1</MMGRT> <MMVLT>-2</MMVLT> <MSCRT>-1</MSCRT> <MSGRT>1</MSGRT> <MSVLT>-2</MSVLT> </OneWeek> <OneYear> <MLCRT>2</MLCRT> <MLGRT>2</MLGRT> <MLVLT>2</MLVLT> <MMCRT>2</MMCRT> <MMGRT>2</MMGRT> <MMVLT>2</MMVLT> <MSCRT>2</MSCRT> <MSGRT>1</MSGRT> <MSVLT>2</MSVLT> </OneYear> <ThreeMonth> <MLCRT>1</MLCRT> <MLGRT>1</MLGRT> <MLVLT>-1</MLVLT> <MMCRT>2</MMCRT> <MMGRT>2</MMGRT> <MMVLT>1</MMVLT> <MSCRT>1</MSCRT> <MSGRT>2</MSGRT> <MSVLT>1</MSVLT> </ThreeMonth> <ThreeYear> <MLCRT>2</MLCRT> <MLGRT>2</MLGRT> <MLVLT>2</MLVLT> <MMCRT>2</MMCRT> <MMGRT>2</MMGRT> <MMVLT>3</MMVLT> <MSCRT>2</MSCRT> <MSGRT>2</MSGRT> <MSVLT>2</MSVLT> </ThreeYear> </Barometer> </Response>''' def parsedResponse=new XmlSlurper().parseText(response)//directly pass //text for response, then remove above response defintion if you need def actualElementSize = parsedResponse.children().children().size() assert 6 == actualElementSize
Related Content
- 26 days agoMisterB
- 2 years agoparmarm
- 6 years agoamarnath1234
- 6 years agoamarnath1234
- 4 years agogdave
Recent Discussions
- 3 hours agoLukaszK