[xquery-talk] Query the attributes
John Snelson
john.snelson at marklogic.com
Thu May 23 01:53:47 PDT 2013
On 23/05/13 09:34, Mailing Lists Mail wrote:
> I was trying to query the atribute value using Xquery in MarkLogic and
> no matter what, I dont seem to be printing the value...
> So this is what I do...
>
> for $college at $position in $doc//college
> return
> <div>
> {$college/name}
> </div>
> <div>
> {$college/@id}
> </div>
In both those cases you're selecting nodes, and the nodes are being
added to the result tree. I suspect the browser is displaying the name,
as it is an element with text content, but the "id" attribute is added
as an attribute, which browsers don't display.
In both cases what you really want is probably the string value of those
nodes, which you can get be calling the string() function on them.
John
--
John Snelson, Lead Engineer http://twitter.com/jpcs
MarkLogic Corporation http://www.marklogic.com
More information about the talk
mailing list