Introduce DataBase,Asp.net,JavaScript,Xml,Html,Css,Sql,Php,ASP.NET Controls,AJAX,Tools,HTML,CSS,JavaScript,Open Source Project,WPF,.Net Framework,Linq
Top Recommended Hosting

Xml XQuery Enclosed Expressions

by the3factory 4/14/2008 6:36:00 AM

In literal XML constructors, you can use curly braces ({}) to add content that is computed when the query is run. This is called an enclosed expression. For example, in the previous example, if you want all of the <Name> elements to appear within an XML root element named <ProductNames>. This could be accomplished with the following XQuery expression:

     <ProductNames>
{ doc("Products.xml")/Products/Product[@Category="Socks"]//Name }
</ProductNames>

With this addition, the output would be as follows:

     <ProductNames>
<Name>Mountain Bike Socks, M</Name>
<Name>Mountain Bike Socks, L</Name>
</ProductNames>

Note that in this query, you used curly braces around the XPath expression within the <ProductNames> element. The braces denote that the content within the braces is an XQuery expression, and not literal content. For example, the following query omits the braces:

     <ProductNames>
doc("Products.xml")/Products/Product[@Category="Socks"]//Name
</ProductNames>

The output of this query would be as follows:

     <ProductNames>
doc("Products.xml")/Products/Product[@Category="Socks"]//Name
</ProductNames>

Related posts

Sign up for PayPal and start accepting credit card payments instantly.


Powered by BlogEngine.NET 1.2.0.0