欢迎光临
我们一直在努力

在.Net1.2中对Xquery的支持-.NET教程,.NET Framework

建站超值云服务器,限时71元/月

在.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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 在.Net1.2中对Xquery的支持-.NET教程,.NET Framework
分享到: 更多 (0)

相关推荐

  • 暂无文章