# Unable to get value from xml (response)

**URL:** <https://forum.katalon.com/t/unable-to-get-value-from-xml-response/11322>\
**Category:** Miscellaneous\
**Tags:** api-testing, katalon-studio\
**Created:** [June 2, 2018, 12:08pm UTC](https://forum.katalon.com/t/unable-to-get-value-from-xml-response/11322 "2018-06-02T12:08:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyle\_Yao](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kyle\_Yao](https://forum.katalon.com/u/Kyle_Yao)\
**Post date:** [June 2, 2018, 12:08pm UTC](https://forum.katalon.com/t/unable-to-get-value-from-xml-response/11322/1 "2018-06-02T12:08:03Z")

</div>

Hi All, could you please help

I got following kinds of response of API.

5

```
  <ItemNumber>345158</ItemNumber>

  <RequestQuantity></RequestQuantity>

  <RequestUnitOfMeasure></RequestUnitOfMeasure>

  <RequestNetPrice></RequestNetPrice>

  <RequestExtendedPrice></RequestExtendedPrice>

  <OrderQuantity></OrderQuantity>

  <OrderUnitOfMeasure></OrderUnitOfMeasure>

  <OrderNetPrice></OrderNetPrice>

  <OrderExtendedPrice></OrderExtendedPrice>

  <Warning/>

  <Error/>

```

 ... ... 

But when I use following method to get the value  
WSBuiltInKeywords.verifyElementText(response, ‘mainResult .Row[3].ItemNumber’, ‘345158’, FailureHandling.OPTIONAL)

I got following result:  
PM - [WARNING] - Expected text is ‘345158’ but actual element text is:

Seems like that the text value is not get.

I’m not sure the element locator is correct or not. Any suggestions?

BTW  
The response contains  
  
…

Is there any way that can get the count of this element ? So i can write loop case.

Thanks & Regards !  
kyle

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [June 3, 2018, 5:19am UTC](https://forum.katalon.com/t/unable-to-get-value-from-xml-response/11322/2 "2018-06-03T05:19:25Z")

</div>

This post may help

> **[How to get array size based on an element found using Xpath?](http://forum.katalon.com/discussion/2006/how-to-get-array-size-based-on-an-element-found-using-xpath)**
>
> This is what I usually write in Selenium webdriver when I want to find size of an array/table.  

This post is talking about accessing response in HTML. Accessing XML response might be similar, but I have never tried yet.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [June 3, 2018, 5:24am UTC](https://forum.katalon.com/t/unable-to-get-value-from-xml-response/11322/3 "2018-06-03T05:24:15Z")

</div>

…

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [June 3, 2018, 5:34am UTC](https://forum.katalon.com/t/unable-to-get-value-from-xml-response/11322/4 "2018-06-03T05:34:44Z")

</div>

…

---

<div class="post-metadata">

**Author:** ![Kyle\_Yao](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kyle\_Yao](https://forum.katalon.com/u/Kyle_Yao)\
**Post date:** [June 3, 2018, 11:06am UTC](https://forum.katalon.com/t/unable-to-get-value-from-xml-response/11322/5 "2018-06-03T11:06:26Z")

</div>

Thanks kazurayam,  
Finally I wrote a customer keyword to convert the responseText into xml and get the tag values. I’m not sure whether is an easy way to do this.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [June 4, 2018, 12:01am UTC](https://forum.katalon.com/t/unable-to-get-value-from-xml-response/11322/6 "2018-06-04T00:01:29Z")

</div>

Good to hear your success.

Just for your interest, I have ever develop a custom keyword to extract texts in HTML and return them as an instance of java.util.List

> **[Custom Keyword: get contents of HTML elements as a list of strings](http://forum.katalon.com/discussion/6992/custom-keyword-get-contents-of-html-elements-as-a-list-of-strings)**
>
> \# Problem to solve Supposing the target web page has a list of element.
