user3932408
user3932408

Reputation: 1

Accessing the xml using xpath

I am getting xpath from database as character. I want to retrieve that element from XML using esql. Since the xpath is character , I am not able to retrieve the element from XML. Is any way to convert the character to refer the XML? For example, my xml is

<?xml version="1.0"?> 
<catalog> 
<book id="bk101"> 
<author>Gambardella, Matthew</author> 
<title>XML Developer's Guide</title> 
<price>44.95</price> 
<publish_date>2000-10-01</publish_date> 
</book> 
<diary> 
<abc>sample</abc> 
</diary> 
</catalog>

and I get the path catalog.book from database as character. I want to retrieve element book for further processing. But since catalog.book is character, I am not able to retrieve the element. Please suggest a method for doing this in esql.

Upvotes: 0

Views: 1487

Answers (1)

Miroslav Pohoraly
Miroslav Pohoraly

Reputation: 53

You can access field by referencing to path stored in variable if you put variable name into {} brackets.

Like this:

DECLARE fieldPath CHARACTER;
SET fieldPath = ........ ;
SET Environment.Variables.Book = InputRoot.MRM.{fieldPath};

Upvotes: 0

Related Questions