How to use an if-else condition in a SAPUI5 XML-View?

OpenUI5 supports Preprocessing Instructions and Expression Binding.

With Preprocessing Instructions you can do stuff like this:

<template:if test="{marketed}">
    <template:then>
        <Label text="product is marketed" />
    </template:then>
    <template:else>
        <Image src="path.jpg" />
    </template:else>
</template:if>

I am not sure if the test in the first line tests for null/not null or true/false. This is where the Expression Binding might be handy: it allows for complex expressions within the curly brackets:

<template:if test="{= ${marketed} === true}">

Edit

The following solution might be more simple, but seems a little hacky.

Embed both elements in your XML view, but toggle the visibility with complex expression binding:

<Label text="product is marketed" visible="{= ${marketed} === true}"/>
<Image src="path.jpg" visible="{= ${marketed} === false}"/>

I am not sure I got your requirement, but it looks like simply binding the visible attribute to the marketed-flag would do.

If you need to bind in a negated way you can use expression binding like

 visible="{= !${/marketed}}"