Using ESQL SELECT statement
The SELECT function combines, filters, and transforms complex message and database data.
Input xml:
-------------
<Person>
<Details>
<ID>1</ID>
<Name>Arun</Name>
</Details>
<Details>
<ID>5</ID>
<Name>Shyam</Name>
</Details>
<Details>
<ID>1</ID>
<Name>Arun</Name>
</Details>
<Details>
<ID>3</ID>
<Name>Priyesh</Name>
</Details>
</Person>
Scenario :
------------
From above input we need name when ID=5.
To get this, the best approach in esql is bellow -
Solution :
------------
--Declare a reference to the root.
DECLARE InRef REFERENCE TO InputRoot.XMLNSC.Person;
--Now assign the value to output using select function
SET OutputRoot.XMLNSC.Data.Person.Name = THE(select item fieldvalue(r.Name) from InRef.Details[] as r where r.ID = 5);
No comments:
Post a Comment