How can I get the value of any tag (e.g. Quantity
) from the below XML by passing the tag name without using hard coded tag name-
def temp1="""
<TradeRecord>
<TradeId>1000</TradeId>
<SecurityId>10382456</SecurityId>
<TradeType>SELLL</TradeType>
<TradeDate>2014-03-21</TradeDate>
<Broker>100</Broker>
<Exchange>1</Exchange>
<Status>INIT</Status>
<Quantity>125</Quantity>
<ApprovedBy />
</TradeRecord>
"""
def records = new XmlParser().parseText(temp1)
//log.info records.Quantity[0].text() By using this i am getting value but i want 'Quantity' to come from a string
tag = 'Quantity'
xy = records["Quantity"].value; 'This is not working
log.info xy