This question was closed Apr 21, 2020 at 04:42 PM by Mynyna Chau for the following reason: The question is answered, right answer was accepted
Dear Experts,
Need a way to query a local XML type property and get all rows of a rowset that match a criteria. We need to do this without using a loop on a result set because using loops currently is making the transaction hang and the gives a transaction timeout error after some time. Example of what we intend to do: Bookstore_XML is a local property of XML type containing:
<?xml version='1.0'?>
<bookstore>
<book> <title>abc</title> <author>Enid</author> <price>10</price> </book>
<book> <title>def</title> <author>Enid</author> <price>20</price> </book>
<book> <title>ghi</title> <author>Jone</author> <price>30</price> </book>
<book> <title>jkl</title> <author>Jone</author> <price>40</price> </book>
</bookstore>
I need to select all books from the bookstore where author = 'Enid'. Output like below:
<?xml version='1.0'?> <bookstore>
<book> <title>abc</title> <author>Enid</author> <price>10</price> </book>
<book> <title>def</title> <author>Enid</author> <price>20</price> </book>
</bookstore>
I try doing like:
Local.Bookstore_XML{//bookstore/book[author='Enid']}
... and assign XML to an XML type property. But I get a blank result.
Any pointers would be highly appreciated.
Regards,
Saumya Govil
Hi Saumya,
You can follow the following steps, hope it will help you.
Steps are as follows:
1) Repeat on "book" using repeater.
2) Filter the row based on author using condition block
3) Create a local variable using the below format,
<?xml version="1.0" encoding="UTF-8" standalone="no"?><book>
<title/>
<author/>
<price/>
</book>
4) Assign the value from repeater to that local variable XML
5) Create another local variable using the below format,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bookstore/>
6) Now append the book XML to the upper mentioned XML like that,
7) Finally create a Output variable in transaction variable and assign Bookstore XML there.
I hope it will help you, and it will solve your problem. The output you will get like that.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bookstore>
<book>
<title>abc</title>
<author>Enid</author>
<price>10</price>
</book>
<book>
<title>def</title>
<author>Enid</author>
<price>20</price>
</book>
</bookstore>
Regards,
Suman
Add a comment