Reputation: 976
I need to insert the element in XML , so I have trying to create the some XML format using XQuery but its not working.
Query :
let $a := 'test'
return
<p name="uri" value= $a />
Expected output :
<p name="uri" value= "test" />
Kindly evaluate this .
Upvotes: 1
Views: 203
Reputation: 7132
Try this:
let $a := 'test'
return
<p name="uri" value="{$a}" />
Or:
let $a := 'test'
return
<p name="uri">{ attribute value { $a } }</p>
The second expression provides a way to construct the name dynamically too as { $value }
. Any attribute nodes constructed or placed inside an element body will be added as regular attributes of the element.
Upvotes: 4