易截截图软件、单文件、免安装、纯绿色、仅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>
# ......

Flex调用远程XML数据

首先要有一个简易的服务器,建立一个站点,然后站点下存放 
1:crossdomain.xml 这个是跨与域策略文件,用于指定域通过Flash
Player访问本域的资源(如果服务器在本机就没有这个必要)但是远程的话就要(建议要)
文件内容:
<cross-domain-policy>
  <allow-access-from domain="*" /> ......

Xml序列化和反序列化

经常见XML序列化的文章,对该序列化方式并不是太晓得,看了MSDN和一些资料后有了大致的了解,大道理讲不出来,上 代码先:
方式一 通过XmlSerialize直接序列化:
Class BeSerialized
{
//某字段
public int someFiled; 
//公共类的一个可序列化的属性
private bool serialme;
public bool SerialMe
{
  ......

关于XML中字节写入流字段时的说明

方法一:
      采取通用的base64编码方式,取时解码存时加码。
毛老师提供了完整的编码代码,且效率很高。
unit Base64;

interface

uses SysUtils, Classes;

type
{$IFDEF UNICODE}
Base64String = AnsiString;
{$ELSE}
Base64String = strin ......

由xml生成xsd及实体类

使用VS2005工具XSD.exe(SDK\v2.0\Bin\xsd.exe)自动生成实体类:
xsd /c /namespace:myCompany /language:CS temp1.xsd
也可以生成DataSet类型的类:
xsd /dataset /language:CS temp1.xsd
 ( 类文件和XSD之间可以相互转换,也就是说,你也可以先生成类,然后自动生成XSD)
    自动读取XML数据 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号