我有这个来自 sql server 的文件输出:
<ProductList>
<Product>
<Product_Department>Sales</Product_Department>
<Product_Category>A</Product_Category>
<Code>AA</Code>
<Description>AAA</Description>
<Price>10</Price>
</Product>
.
.
.
<Product>
.
.
.
</Product>
</ProductList>
sql脚本是:
create proc xmlcollection
as
declare @XmlOutput xml
set @XmlOutput = (select * from Product
FOR XML AUTO, ROOT('ProductList'), ELEMENTS)
select @XmlOutput
go
xml 文件的所需输出将是:
<ProductList>
<Product DEP="Sales" CAT="A" CODE="AA" PRICE="10"></Product>
<Product.........................................></Product>
.
.
.
</ProductList>
如何从 FOR XML 子句中做到这一点?请帮忙。