
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi All,
I used Web Service Protocol in my script and added the XML script before Action(). Following is my script:
#include "as_web.h"
char *xml_input=
"<MySchool>"
"<teacher>"
"<name>"
"<firstname>MyTeacher</firstname>"
"<lastname>Gauda</lastname>"
"</name>"
"<address>"
"<street>101 South Street</street>"
"<city>Dehradun</city>"
"<email>saranya.rajaram@abc.com</email>"
"<phone>8015499</phone>"
"</address>"
"</teacher>"
"<student>"
"<name>"
"<firstname>Tinku</firstname>"
"<lastname>Raja</lastname>"
"</name>"
"<address>"
"<street>102 North Street</street>"
"<city> Bangalore </city>"
"<email>tinku.raja@xyz.com</email>"
"<phone>8015498</phone>"
"</address>"
"</student>"
"</MySchool>";
Action()
{
/* Query 3: Find the city name of the person whose phone number is 8015498 */
lr_xml_get_values("XML={XML_Input_Param}",
"ValueParam=Result",
"Query=/MySchool/*/address[phone=\"8015498\"]/city",
LAST );
lr_output_message("City of the person having phone number 8015498: %s", lr_eval_string("{Result}"));
* In the above, since city is at the same level as phone, so it worked.
/* Query 2: Find the firstname of the person whose phone number is 8015498 */
lr_xml_get_values("XML={XML_Input_Param}",
"ValueParam=Result",
"Query=/MySchool/*/address[phone=\"8015498\"]/?",
LAST );
lr_output_message("First name of person having phone number 8015498: %s", lr_eval_string("{Result}"));
return 0;
}
*In the above, since the firstname is not at the same level as phone, I tried some path but it did not work.
By what string should I replace ? to get the firstname of the person whose phone number is 8015498 ?
Best,
Sachin
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi
You can use levels in the search queries also and should think of the [ ] as having.
In your example this would mean
"Query=/MySchool/student[address/phone=\"8015498\"]/name/firstname",
or explained - student having adress with phone 8015498
br /ola
Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi
This looks to much like a schoolassgniment to give the right answer directly. 🙂
Also it is nothing related to LoadRunner or it's implementation, just about creating an xpath that gets you the correct data
So look for a xpath-tutorial like http://www.w3schools.com/xml/xpath_intro.asp or similar. Will help you a lot more than to provide the answer.
br /ola
Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Ola Berggren,
As per your advice, I went through the tutorial and tried many times, but I am unable to fetch the first name of the person on the basis of his extension number.
I am able to fetch the values that are at the same level. For example, the first name of the person whose last name is 'Raja', city name of the person whose phone number is 8015498.
I am looking for your valuable comments.
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi
You can use levels in the search queries also and should think of the [ ] as having.
In your example this would mean
"Query=/MySchool/student[address/phone=\"8015498\"]/name/firstname",
or explained - student having adress with phone 8015498
br /ola
Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Joshi,
below Quary is working for both the cases, i.e student and teacher
"Query=/MySchool/*[address/phone=\"8015499\"]/name/firstname",
Thanks,
Ravi Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Ola Berggren,
Many thanks!
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Ravi,
Many thanks!
Regards,
Sachin