Darren_Sniezak_40

How to pull an xml attribute when using PREP_PROCESS_VAR_XML

Discussion created by Darren_Sniezak_40 on Jun 6, 2016
The common use of PREP_PROCESS_VAR_XML will pull the values from within XML tags, but if you are in a situation where you need to take the attributes of a XML tag instead, you can do this with utilizing XPATH in the value of the variable.

For example, if you had an XML Variable with a key of UserInterface and a value of:
<connection name="test" system="test"><cp ip="10.2.128.254" port="2217"/><cp ip="10.2.128.254" port="2218"/><cp ip="10.2.128.254" port="2219"/><cp> </cp><wp test="test"></wp></connection> 

You could use: 
:SET &HND# = PREP_PROCESS_VAR_XML(VARA.XML,"UserInterface","/connection/cp/@port") 
:PROCESS &HND# 
: SET &LINE# = GET_PROCESS_LINE(&HND#,1) 
: P &LINE# 
:ENDPROCESS 

To return: 
U00020408 2217 
U00020408 2218 
U00020408 2219



Outcomes