I'm having trouble designing an XQuery. My XML looks like a Pokemon database:
<species id="a0001">
<name></name>
<description></description>
<type></type>
<type></type> (can have different types)
<type></type>
<attack>
<has-attack id="p01"/>
<has-attack id="p02"/>
</attack>
<evolution>
<species id="a0002">
.
.
.
<evolution>
<species id="a0003">
.
.
.
</species>
</evolution>
</species>
<species id="a0004">
.
.
.
</species>
</evolution>
</species>
What I'm trying to do is get all species with the type "Fire".
declare variable $tipo as xs:string := "Fire";
for $b in doc("doc.xml")/bd/species
let $nattacks:= count ($b/attacks)
where $b/type= $type
return <result>
{$b/@id}
{$b/name}
<na>{$nattacks}</na>
</result>
But I don't know how to access to the species inside the "Evolutions" label. Any help?
//speciesto find allspecieselements in the entire XML :doc(".xml")//species. What's the problem with that? - har07