open the file: doc("xxx.xml")
doc("xxx.xml")/bookstore/book[conditon clause]
for, where, order, return
doc("xxx.xml")/bookstore/book[price>20]/title
=
for $x in doc("xxx.xml")/bookstore/book
where $x/price>20
order by $x/title
return $x/title
integrate with html tags
<ul>
for $x in doc("xxx.xml")/bookstore/book/title
oder by $x
return <li>($x)</li>
</ul>
get the data directly use the data() function
ex:
<ul>
for $x in doc("xxx.xml")/bookstore/book/title
return <li>(data|($x))</li>
</ul>
basic syntax rules
comment: (: I am comment :)
"if-then-else":
for $x in doc("xxx.xml")/bookstore/book
return if ($x/@attribute="hey")
then <child>(data($x/title))</child>
else <adult>(data($x/title))<adult>
comparisons:
one group: =, !=, <, <=, >, >=
another group: eq, ne, lt, le, gt, ge
what's the difference? see the follow two examples
$bookstore//book/@q > 20 --> if any items fulfill the condition, then return true
$bookstore//book/@q lt 20 --> only one item fulfill the condition, then return true
use function
default functions: upper-case, substring, data, and so on...
custom function:
declare function prefix:function_name($parameter AS datatype)
AS returnDataType{
...
}