For xml explicit mode FOR further application

Source: Internet
Author: User
In the previous article, we briefly explained the most basic application of various fox xml modes. Now we need to describe more about the EXPLICIT it mode in the fourth mode: Suppose we want to generate the following XML document:
<Employee empid="1">
<Name>
<FName>Nancy</FName>
<LName>Davolio</LName>
</Name>
</Employee>
 
SQL statement:
-- Define the data structure of the output XML document
SELECT  1 AS Tag,
        NULL AS Parent,
        EmployeeID AS [employee!1!empid],
        FirstName AS [Name!2!FName!element],
        LastName AS [Name!2!LName!element]
FROM    Employees
UNION ALL
-- Input actual data
SELECT  2 AS Tag,
        1 AS Parent,
        EmployeeID,
        FirstName,
        LastName
FROM    Employees
ORDER BY [Employee!1!empid],
        [Name!2!FName!element],
        [Name!2!LName!element]
FOR     XML EXPLICIT

Tag value 2 indicates FirstName, and the parent element of LastName is Name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.