2009/11/24 Roland Butler <rbut...@businessmonitor.com>:
> I am able to use xquery to display the text associated with an element as
> follows
>
> <
>
> title type="main">Document Title</title>
>
> <h1>{($article/bk:head/bk:title/text())}</h1>
>
>
> But how can I get to attribute of an element?
>
> <
>
> meta name="name" content="value"/>
> I want to print out the value text but don't know how?

Unlike elements, attributes are single nodes and don't have text()
node children, and selecting the attribute adds that attribute node to
the result.

To get the value of the attribute you need to use the fn:string()
function, using:

fn:string(meta/@content)

or

meta/@content/fn:string(.)




-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to