예제: CDATA 지시어 지정Example: Specifying the CDATA Directive

지시어가 CDATA로 설정되면 포함된 데이터가 엔터티 인코딩되지는 않지만 CDATA 섹션에 놓여집니다.If the directive is set to CDATA, the contained data is not entity encoded, but is put in the CDATA section. CDATA 특성은 이름이 없어야 합니다.The CDATA attributes must be nameless.

다음 쿼리는 제품 모델 요약 설명을 CDATA 섹션에 포함시킵니다.The following query wraps the product model summary description in a CDATA section.

USE AdventureWorks2012;  
GO  
SELECT  1 as Tag,  
        0 as Parent,  
        ProductModelID  as [ProductModel!1!ProdModelID],  
        Name            as [ProductModel!1!Name],  
        '<Summary>This is summary description</Summary>'     
            as [ProductModel!1!!CDATA] -- no attribute name so ELEMENT assumed  
FROM    Production.ProductModel  
WHERE   ProductModelID=19  
FOR XML EXPLICIT  

다음은 결과입니다.This is the result:

<ProductModel ProdModelID="19" Name="Mountain-100">  
   <![CDATA[<Summary>This is summary description</Summary>]]>  
</ProductModel>  

참고 항목See Also

FOR XML에서 EXPLICIT 모드 사용Use EXPLICIT Mode with FOR XML