0
私はXMLNAMESPACES
節の主な目的がネームスペースを宣言し、さらにそれを使用することを理解しています。XMLNAMESPACESエイリアスを表示しない方法
私は次のように出力
<q17:OrderedProducts xmlns:q17="http://ITrack.Transmission/2011/02/25/Objects">
<q17:OrderedProductSection xmlns:q17="OrderedProductSection">
<q17:ProductCode>19A0010000</q17:ProductCode>
<q17:OrderedQuantity>2</q17:OrderedQuantity>
</q17:OrderedProductSection>
<q17:OrderedProductSection xmlns:q17="OrderedProductSection">
<q17:ProductCode>1G5Y010000</q17:ProductCode>
<q17:OrderedQuantity>3</q17:OrderedQuantity>
</q17:OrderedProductSection>
<q17:OrderedProductSection xmlns:q17="OrderedProductSection">
<q17:ProductCode>1G5Y020000</q17:ProductCode>
<q17:OrderedQuantity>4</q17:OrderedQuantity>
</q17:OrderedProductSection>
<q17:OrderedProductSection xmlns:q17="OrderedProductSection">
<q17:ProductCode>1G5Y030000</q17:ProductCode>
<q17:OrderedQuantity>5</q17:OrderedQuantity>
</q17:OrderedProductSection>
<q17:OrderedProductSection xmlns:q17="OrderedProductSection">
<q17:ProductCode>1G5Y040000</q17:ProductCode>
<q17:OrderedQuantity>6</q17:OrderedQuantity>
</q17:OrderedProductSection>
</q17:OrderedProducts>
を生成そして今、解決策を見つけることを望んでばかな質問は、次のコード
DECLARE @XMLFINAL VARCHAR(MAX)
SET @XMLFINAL=''
DECLARE @NUMBER NVARCHAR(100)
DECLARE @XML VARCHAR(MAX)
DECLARE Records CURSOR FAST_FORWARD FOR
SELECT TOP 1 GID FROM PurchasesDocumentsLines
OPEN Records
FETCH NEXT FROM Records INTO @NUMBER
WHILE @@FETCH_STATUS = 0
BEGIN
SET @XML=''
;WITH XMLNAMESPACES ('OrderedProductSection' as q17)
SELECT @XML= (
SELECT
ProductCode as 'q17:ProductCode', OrderedQuantity 'q17:OrderedQuantity'
FROM PurchasesDocumentsLines WHERE [email protected]
FOR
XML RAW('q17:OrderedProductSection'), ELEMENTS
)
持っている:<q17:OrderedProductSection xmlns:q17="OrderedProductSection">
タグのことどのような方法がありますが、 xmlns:q17="OrderedProductSection"
は表示されませんか?なぜなら、空のURIを持つことは許されないからです。おかげ
LEは
REPLACE
機能とそれを実現します。
編集
<q17:OrderedProducts xmlns:q17="http://ITrack.Transmission/2011/02/25/Objects">
<q17:ProductCode>19A0010000</q17:ProductCode>
<q17:OrderedQuantity>2</q17:OrderedQuantity>
<q17:ProductCode>1G5Y010000</q17:ProductCode>
<q17:OrderedQuantity>3</q17:OrderedQuantity>
</q17:OrderedProducts>
を返しますが、 'root'を避け、コードを作るためにどのような方法があります私の編集のように見える?ありがとうございます – cdrrrrr
@cdrrrrr 'はどこですか? –
Shnugo
@cdrrrrr編集時に本当に必要な場合は簡単です(ただし、この構造は提案しません)。最後のコード行を 'FOR XML PATH( '')、ROOT( 'q17:OrderedProducts');'に置き換えてください。空の 'PATH( '')'は行ラッピングノードなしで返します – Shnugo