易截截图软件、单文件、免安装、纯绿色、仅160KB

Integration with the XML Data Type

Integration with the XML Data Type
With the introduction of the XML data type, we wanted to also give FOR XML the ability to generate an instance of XML directly (more precisely, it generates a single row, single column rowset where the cell contains the XML data type instance).
Because of the backwards-compatibility considerations outlined above, we added a new TYPE directive to generate the result as XML. For example,
Copy
SELECT * from Customers FOR XML AUTO, TYPE
returns the Customers elements as an XML data type instance, instead of the nvarchar(max) instance that would have been the case without the TYPE directive.
This result is guaranteed to conform to the well-formedness constraints provided by the XML data type. Since the result is an XML data type instance, you can also use XQuery expressions to query and reshape the result. For example, the following expression retrieves the Customer contact name into a new Person element.
Copy
SELECT (SELECT * from Customers FOR XML AUTO, TYPE).query(
'<doc>{
for $c in /Customers
return
<Person name="{data($c/@ContactName)}"/>
}</doc>')
returns (only first elements shown),
Copy
<doc>
<Person name="Maria Anders" />
<Person name="Ana Trujillo" />
<Person name="Antonio Moreno" />
...
</doc>
Assigning FOR XML Results
Since FOR XML queries now return assignable values, the result of a FOR XML query can be assigned to a variable, or inserted into a column.
Copy
DECLARE @cust XML;
SET @cust = (SELECT * from Customers FOR XML AUTO, TYPE)
CREATE TABLE T(i int, x XML)
INSERT INTO T SELECT 1, (SELECT * from Customers FOR XML AUTO, TYPE)
Nesting of FOR XML Expressions
FOR XML, in SQL Server 2005, recognizes XML data type columns, and will inline them as sub-elements. Thus, we can nest FOR XML queries to generate hierarchies, instead of having to rely on the AUTO mode heuristic, or writing an EXPLICIT mode query.
Let's look


相关文档:

C++ 操作XML的完整例子——MSXML篇

写本文的目的是为了方便大家了解C++ MSXML操作方法。
当然,C++中对MSXML的调用有多种,本文采用的方法是完全参照MSXML SDK提供的文档进行操作。
如果有什么错误,欢迎指正。
代码框架是基于vs2008 MFC 对话框程序(UNICODE)。对话框程序需要读者自己创建。
#include <msxml6.h>
#include <comutil.h>
# ......

.Net的精髓——XML和SOAP

Internet 的应用正在不断地扩大,但我们的 Internet 编程方式还处于石器时代。Internet 用户就像老式主机的分时终端上的用户一样,他们从一个受保护的资源请求信息,然后等待回应。你从正在浏览的 Internet 站点上接收的信息由它希望提供给你的、基于 HTML 的信息组成的。
  但是,同远程 Web 站点进行交互式操作是不是 ......

XMLTextReader对XML文件的读取

using System;
using System.Xml;
namespace ReadXMLfromFile
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
XmlTextReader reader = new XmlTextReader ("books.xml");
......

数据库查询XML结构,FOR XML PATH 语句的应用


/*
数据库查询XML结构,FOR XML PATH 语句的应用
*/
FOR XML PATH 语句的应用:
CREATE  TABLE TempTable(UserID int , UserName nvarchar(50));
insert into TempTable (UserID,UserName) values (1,'a')
insert into TempTable (UserID,UserName) values (2,'b')
select UserID,UserName from TempTable FOR ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号