Reputation: 49
<pizzeria>
<logo>logo.jpg</logo>
<pizzas>
<pizza id="p001">
<nombre>Carbonara</nombre>
<imagen>carbonara.jpg</imagen>
</pizza>
<pizza id="p002">
<nombre>Barbacoa</nombre>
<imagen>barbacoa.jpg</imagen>
</pizza>
<pizza id="p003">
<nombre>Gourmet</nombre>
<imagen>gourmet.jpg</imagen>
</pizza>
<pizza id="p004">
<nombre>Boloñesa</nombre>
<imagen>bolonesa.jpg</imagen>
</pizza>
</pizzas>
</pizzeria>
They ask me to put the logo image and the other images (the other images in a table) in exist db using FLWOR. The images are stored in a folder called "images". If you need any more info, please, tell me.
I tried this:
{
for $h in doc("/db/exercise/pizzeria.xml")//pizza
return
<tr>
<td>{$h/imagen}</td>
</tr>
}
But it obviously didn't work.
Upvotes: 1
Views: 40
Reputation: 66781
If you are generating HTML, then you want an img
element with the @src
attribute pointing to that image file:
{
for $h in doc("/db/exercise/pizzeria.xml")//pizza
return
<tr>
<td><img src="images/{$h/imagen/text()}" alt="{$/nombre/text()}"/></td>
</tr>
}
Upvotes: 1