I need to select a node if a condition is matched. I’m totally new in XSLT and tried to search for an answer but can’t find a solution that works for me.
I want to select an adres when there is an AddressType = ‘Personal’, if there’s not an AddressType = Personal, check for ‘Second’, if not check for ‘Office’.
A normal If Else.
I tried with and and this could work if only one type of AddressType would exist in the XML file. In my case there can be up too 11 addressTypes (in random order) in the XML file and I can only pass one through.
This looks like my source XML:
<Person>
<address>
<street></street
<number></number>
<City></City>
<AddressType>Personal</AddressType>
</address>
<address>
<street></street
<number></number>
<City></City>
<AddressType>Second</AddressType>
</address>
<address>
<street></street
<number></number>
<City></City>
<AddressType>Office</AddressType>
</address>
</Person>
Any advice? thank you
You need to use
<xsl:choose>