您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200509
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

在.Net1.2中对Xquery的支持

guoyan19811021

在.Net1.2中支持Xquery,Xquery使用一种叫FLWOR的查询语言(音Flower).例子如下:

using System;
using System.IO;
using System.Xml;
using System.Xml.Query;
using System.Data.SqlXml;
namespace XQuery{
public class XQuerySample{  
public static void Main(string[] args)  {    
System.Xml.XmlDataSourceResolver ds = new System.Xml.XmlDataSourceResolver ();    
ds.Add("bookstore","books.xml");    
StreamWriter writer=new StreamWriter("output.xml");   
 string query=@"<bookstore>      {        
 for $b in document(´bookstore´)/bookstore/book        
 where $b/@genre=´philosophy´ and $b/@publicationdate=´1991´       
 return $b/title       
}    
</bookstore>";    
XQueryProcessor xp = new XQueryProcessor ();    
xp.Compile(query);    
xp.Execute(ds, writer);    
writer.Close();  
}  
}
}

books.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This file represents a fragment of a bookstore database -->
<bookstore> 
 <book genre="autobiography" publicationdate="1981" ISBN="1-861-11-0">  
  <title>The Autobiography of Benjamin Franklin</title>   
 <author>      
  <first-name>Benjamin</first-name>     
   <last-name>Franklin</last-name>   
</author>   
 <price>8.99</price>  
</book>  
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">    
<title>The Confidence Man</title>   
 <author>      
<first-name>Herman</first-name>      
<last-name>Melville</last-name>   
</author>    
<price>11.99</price>  
</book>  
<book genre="philosophy" publicationdate="1991"   ISBN="1-861001-57-6">  
 <title>The Gorgias</title>    
<author>      
<name>Plato</name>    
</author>    
<price>9.99</price>  
</book>
</bookstore>

output.xml

<?xml version="1.0" encoding="utf-8"?>
<bookstore>
<title>The Gorgias</title>
</bookstore>