1

我想使用 SQL Server 以将以下 XML 示例转换为平面表的方式查询 XML 文件:

<?xml version="1.0" ?> 
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
  <ns1:getArtifactDetailListResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://schema.open.collab.net/sfee50/soap60/service">
  <getArtifactDetailListReturn href="#id0" /> 
  </ns1:getArtifactDetailListResponse>
  <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:ArtifactDetailSoapList" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://schema.open.collab.net/sfee50/soap60/type">
  <dataRows soapenc:arrayType="ns2:ArtifactDetailSoapRow[4]" xsi:type="soapenc:Array">
  <dataRows href="#id1" /> 
  <dataRows href="#id2" /> 
  <dataRows href="#id3" /> 
  <dataRows href="#id4" /> 
  </dataRows>
  <fullListSize xsi:type="xsd:int">4</fullListSize> 
  </multiRef>
  <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:ArtifactDetailSoapRow" xmlns:ns3="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <actualEffort xsi:type="xsd:int">0</actualEffort> 
  <artifactGroup xsi:type="xsd:string" /> 
  <assignedToFullname xsi:type="xsd:string">Anon User</assignedToFullname> 
  <assignedToUsername xsi:type="xsd:string">anon_user</assignedToUsername> 
  <autosumming xsi:type="xsd:boolean">false</autosumming> 
  <category xsi:type="xsd:string">Internal Improvement</category> 
  <closeDate xsi:type="xsd:dateTime" xsi:nil="true" /> 
  <customer xsi:type="xsd:string" /> 
  <description xsi:type="xsd:string">Description Here</description> 
  <estimatedEffort xsi:type="xsd:int">0</estimatedEffort> 
  <flexFields href="#id5" /> 
  <folderId xsi:type="xsd:string">tracker15657</folderId> 
  <folderPathString xsi:type="xsd:string">tracker.brd_new_request</folderPathString> 
  <folderTitle xsi:type="xsd:string">BRDs (New/Change Requests)</folderTitle> 
  <id xsi:type="xsd:string">artf705037</id> 
  <lastModifiedDate xsi:type="xsd:dateTime">2013-02-01T10:43:02.000Z</lastModifiedDate> 
  <planningFolderId xsi:type="xsd:string" xsi:nil="true" /> 
  <planningFolderTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <points xsi:type="xsd:int">0</points> 
  <priority xsi:type="xsd:int">4</priority> 
  <projectId xsi:type="xsd:string">proj7173</projectId> 
  <projectPathString xsi:type="xsd:string">projects.rapid_application_developmet</projectPathString> 
  <projectTitle xsi:type="xsd:string">Rapid Application Development</projectTitle> 
  <remainingEffort xsi:type="xsd:int">0</remainingEffort> 
  <reportedInReleaseId xsi:type="xsd:string" xsi:nil="true" /> 
  <reportedInReleaseTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <resolvedInReleaseId xsi:type="xsd:string" xsi:nil="true" /> 
  <resolvedInReleaseTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <status xsi:type="xsd:string">RAD Reviewing</status> 
  <statusClass xsi:type="xsd:string">Open</statusClass> 
  <submittedByFullname xsi:type="xsd:string">Anon User</submittedByFullname> 
  <submittedByUsername xsi:type="xsd:string">anon_user</submittedByUsername> 
  <submittedDate xsi:type="xsd:dateTime">2013-02-01T10:43:02.000Z</submittedDate> 
  <title xsi:type="xsd:string">SWAPS - Weekly Tracer Exception Report</title> 
  <trackerIcon xsi:type="xsd:string" xsi:nil="true" /> 
  <version xsi:type="xsd:int">100</version> 
  </multiRef>
  <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:ArtifactDetailSoapRow" xmlns:ns4="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <actualEffort xsi:type="xsd:int">0</actualEffort> 
  <artifactGroup xsi:type="xsd:string" /> 
  <assignedToFullname xsi:type="xsd:string">Anon User</assignedToFullname> 
  <assignedToUsername xsi:type="xsd:string">anon_user</assignedToUsername> 
  <autosumming xsi:type="xsd:boolean">false</autosumming> 
  <category xsi:type="xsd:string">Internal Improvement</category> 
  <closeDate xsi:type="xsd:dateTime" xsi:nil="true" /> 
  <customer xsi:type="xsd:string" /> 
  <description xsi:type="xsd:string">KOP embelished for internal improvement/automation.</description> 
  <estimatedEffort xsi:type="xsd:int">0</estimatedEffort> 
  <flexFields href="#id6" /> 
  <folderId xsi:type="xsd:string">tracker15657</folderId> 
  <folderPathString xsi:type="xsd:string">tracker.brd_new_request</folderPathString> 
  <folderTitle xsi:type="xsd:string">BRDs (New/Change Requests)</folderTitle> 
  <id xsi:type="xsd:string">artf705038</id> 
  <lastModifiedDate xsi:type="xsd:dateTime">2013-02-01T10:49:14.000Z</lastModifiedDate> 
  <planningFolderId xsi:type="xsd:string" xsi:nil="true" /> 
  <planningFolderTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <points xsi:type="xsd:int">0</points> 
  <priority xsi:type="xsd:int">4</priority> 
  <projectId xsi:type="xsd:string">proj7173</projectId> 
  <projectPathString xsi:type="xsd:string">projects.rapid_application_developmet</projectPathString> 
  <projectTitle xsi:type="xsd:string">Rapid Application Development</projectTitle> 
  <remainingEffort xsi:type="xsd:int">0</remainingEffort> 
  <reportedInReleaseId xsi:type="xsd:string" xsi:nil="true" /> 
  <reportedInReleaseTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <resolvedInReleaseId xsi:type="xsd:string" xsi:nil="true" /> 
  <resolvedInReleaseTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <status xsi:type="xsd:string">RAD Reviewing</status> 
  <statusClass xsi:type="xsd:string">Open</statusClass> 
  <submittedByFullname xsi:type="xsd:string">Anon User</submittedByFullname> 
  <submittedByUsername xsi:type="xsd:string">anon_user</submittedByUsername> 
  <submittedDate xsi:type="xsd:dateTime">2013-02-01T10:49:14.000Z</submittedDate> 
  <title xsi:type="xsd:string">SWAPS   Weekly Trade Support Report</title> 
  <trackerIcon xsi:type="xsd:string" xsi:nil="true" /> 
  <version xsi:type="xsd:int">100</version> 
  </multiRef>
  <multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:ArtifactDetailSoapRow" xmlns:ns5="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <actualEffort xsi:type="xsd:int">0</actualEffort> 
  <artifactGroup xsi:type="xsd:string" /> 
  <assignedToFullname xsi:type="xsd:string">Anon User</assignedToFullname> 
  <assignedToUsername xsi:type="xsd:string">anon_user</assignedToUsername> 
  <autosumming xsi:type="xsd:boolean">false</autosumming> 
  <category xsi:type="xsd:string">Internal Improvement</category> 
  <closeDate xsi:type="xsd:dateTime" xsi:nil="true" /> 
  <customer xsi:type="xsd:string" /> 
  <description xsi:type="xsd:string">BRD submitted for internal automation of BAU.</description> 
  <estimatedEffort xsi:type="xsd:int">0</estimatedEffort> 
  <flexFields href="#id7" /> 
  <folderId xsi:type="xsd:string">tracker15657</folderId> 
  <folderPathString xsi:type="xsd:string">tracker.brd_new_request</folderPathString> 
  <folderTitle xsi:type="xsd:string">BRDs (New/Change Requests)</folderTitle> 
  <id xsi:type="xsd:string">artf704445</id> 
  <lastModifiedDate xsi:type="xsd:dateTime">2013-01-30T16:31:35.000Z</lastModifiedDate> 
  <planningFolderId xsi:type="xsd:string" xsi:nil="true" /> 
  <planningFolderTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <points xsi:type="xsd:int">0</points> 
  <priority xsi:type="xsd:int">4</priority> 
  <projectId xsi:type="xsd:string">proj7173</projectId> 
  <projectPathString xsi:type="xsd:string">projects.rapid_application_developmet</projectPathString> 
  <projectTitle xsi:type="xsd:string">Rapid Application Development</projectTitle> 
  <remainingEffort xsi:type="xsd:int">0</remainingEffort> 
  <reportedInReleaseId xsi:type="xsd:string" xsi:nil="true" /> 
  <reportedInReleaseTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <resolvedInReleaseId xsi:type="xsd:string" xsi:nil="true" /> 
  <resolvedInReleaseTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <status xsi:type="xsd:string">RAD Reviewing</status> 
  <statusClass xsi:type="xsd:string">Open</statusClass> 
  <submittedByFullname xsi:type="xsd:string">Anon User</submittedByFullname> 
  <submittedByUsername xsi:type="xsd:string">anon_user</submittedByUsername> 
  <submittedDate xsi:type="xsd:dateTime">2013-01-30T16:29:02.000Z</submittedDate> 
  <title xsi:type="xsd:string">SWAPS Daily MIS Overall Performance</title> 
  <trackerIcon xsi:type="xsd:string" xsi:nil="true" /> 
  <version xsi:type="xsd:int">101</version> 
  </multiRef>
  <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns6:ArtifactDetailSoapRow" xmlns:ns6="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <actualEffort xsi:type="xsd:int">0</actualEffort> 
  <artifactGroup xsi:type="xsd:string" /> 
  <assignedToFullname xsi:type="xsd:string">Anon User</assignedToFullname> 
  <assignedToUsername xsi:type="xsd:string">anon_user</assignedToUsername> 
  <autosumming xsi:type="xsd:boolean">false</autosumming> 
  <category xsi:type="xsd:string">Internal Improvement</category> 
  <closeDate xsi:type="xsd:dateTime" xsi:nil="true" /> 
  <customer xsi:type="xsd:string" /> 
  <description xsi:type="xsd:string">BRD submitted for internal automation of BAU.</description> 
  <estimatedEffort xsi:type="xsd:int">0</estimatedEffort> 
  <flexFields href="#id8" /> 
  <folderId xsi:type="xsd:string">tracker15657</folderId> 
  <folderPathString xsi:type="xsd:string">tracker.brd_new_request</folderPathString> 
  <folderTitle xsi:type="xsd:string">BRDs (New/Change Requests)</folderTitle> 
  <id xsi:type="xsd:string">artf704570</id> 
  <lastModifiedDate xsi:type="xsd:dateTime">2013-01-31T10:27:13.000Z</lastModifiedDate> 
  <planningFolderId xsi:type="xsd:string" xsi:nil="true" /> 
  <planningFolderTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <points xsi:type="xsd:int">0</points> 
  <priority xsi:type="xsd:int">4</priority> 
  <projectId xsi:type="xsd:string">proj7173</projectId> 
  <projectPathString xsi:type="xsd:string">projects.rapid_application_developmet</projectPathString> 
  <projectTitle xsi:type="xsd:string">Rapid Application Development</projectTitle> 
  <remainingEffort xsi:type="xsd:int">0</remainingEffort> 
  <reportedInReleaseId xsi:type="xsd:string" xsi:nil="true" /> 
  <reportedInReleaseTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <resolvedInReleaseId xsi:type="xsd:string" xsi:nil="true" /> 
  <resolvedInReleaseTitle xsi:type="xsd:string" xsi:nil="true" /> 
  <status xsi:type="xsd:string">RAD Reviewing</status> 
  <statusClass xsi:type="xsd:string">Open</statusClass> 
  <submittedByFullname xsi:type="xsd:string">Anon User</submittedByFullname> 
  <submittedByUsername xsi:type="xsd:string">anon_user</submittedByUsername> 
  <submittedDate xsi:type="xsd:dateTime">2013-01-31T10:27:13.000Z</submittedDate> 
  <title xsi:type="xsd:string">SWAPS Heatmap</title> 
  <trackerIcon xsi:type="xsd:string" xsi:nil="true" /> 
  <version xsi:type="xsd:int">100</version> 
  </multiRef>
  <multiRef id="id7" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:SoapFieldValues" xmlns:ns7="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <names soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <names xsi:type="xsd:string">BRD Received</names> 
  <names xsi:type="xsd:string">Dev Started</names> 
  <names xsi:type="xsd:string">EUDA Registered</names> 
  <names xsi:type="xsd:string">Prioritised   Pending Dev</names> 
  <names xsi:type="xsd:string">Product</names> 
  <names xsi:type="xsd:string">Product Group</names> 
  <names xsi:type="xsd:string">Requestor POC</names> 
  <names xsi:type="xsd:string">Signed Off</names> 
  <names xsi:type="xsd:string">UAT Delivered</names> 
  <names xsi:type="xsd:string">UAT Delivery Date</names> 
  <names xsi:type="xsd:string">VP Approval</names> 
  <names xsi:type="xsd:string">BMSC POC</names> 
  <names xsi:type="xsd:string">$fild306322$Coverage</names> 
  <names xsi:type="xsd:string">$fild306551$test</names> 
  </names>
  <types soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  </types>
  <values soapenc:arrayType="xsd:anyType[14]" xsi:type="soapenc:Array">
  <values xsi:type="xsd:dateTime">2013-01-30T08:00:00.000Z</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="soapenc:string">Synthetics</values> 
  <values xsi:type="soapenc:string">GPF</values> 
  <values xsi:type="soapenc:string" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:dateTime">2013-01-30T08:00:00.000Z</values> 
  <values xsi:type="soapenc:string">anon_user</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  </values>
  </multiRef>
  <multiRef id="id8" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns8:SoapFieldValues" xmlns:ns8="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <names soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <names xsi:type="xsd:string">BRD Received</names> 
  <names xsi:type="xsd:string">Dev Started</names> 
  <names xsi:type="xsd:string">EUDA Registered</names> 
  <names xsi:type="xsd:string">Prioritised   Pending Dev</names> 
  <names xsi:type="xsd:string">Product</names> 
  <names xsi:type="xsd:string">Product Group</names> 
  <names xsi:type="xsd:string">Requestor POC</names> 
  <names xsi:type="xsd:string">Signed Off</names> 
  <names xsi:type="xsd:string">UAT Delivered</names> 
  <names xsi:type="xsd:string">UAT Delivery Date</names> 
  <names xsi:type="xsd:string">VP Approval</names> 
  <names xsi:type="xsd:string">BMSC POC</names> 
  <names xsi:type="xsd:string">$fild306322$Coverage</names> 
  <names xsi:type="xsd:string">$fild306551$test</names> 
  </names>
  <types soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  </types>
  <values soapenc:arrayType="xsd:anyType[14]" xsi:type="soapenc:Array">
  <values xsi:type="xsd:dateTime">2013-01-31T08:00:00.000Z</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="soapenc:string">Synthetics</values> 
  <values xsi:type="soapenc:string">GPF</values> 
  <values xsi:type="soapenc:string" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:dateTime">2013-01-31T08:00:00.000Z</values> 
  <values xsi:type="soapenc:string">anon_user</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  </values>
  </multiRef>
  <multiRef id="id6" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns9:SoapFieldValues" xmlns:ns9="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <names soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <names xsi:type="xsd:string">BRD Received</names> 
  <names xsi:type="xsd:string">Dev Started</names> 
  <names xsi:type="xsd:string">EUDA Registered</names> 
  <names xsi:type="xsd:string">Prioritised   Pending Dev</names> 
  <names xsi:type="xsd:string">Product</names> 
  <names xsi:type="xsd:string">Product Group</names> 
  <names xsi:type="xsd:string">Requestor POC</names> 
  <names xsi:type="xsd:string">Signed Off</names> 
  <names xsi:type="xsd:string">UAT Delivered</names> 
  <names xsi:type="xsd:string">UAT Delivery Date</names> 
  <names xsi:type="xsd:string">VP Approval</names> 
  <names xsi:type="xsd:string">BMSC POC</names> 
  <names xsi:type="xsd:string">$fild306322$Coverage</names> 
  <names xsi:type="xsd:string">$fild306551$test</names> 
  </names>
  <types soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  </types>
  <values soapenc:arrayType="xsd:anyType[14]" xsi:type="soapenc:Array">
  <values xsi:type="xsd:dateTime">2013-02-01T08:00:00.000Z</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="soapenc:string">Synthetics</values> 
  <values xsi:type="soapenc:string">GPF</values> 
  <values xsi:type="soapenc:string" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:dateTime">2013-02-01T08:00:00.000Z</values> 
  <values xsi:type="soapenc:string">anon_user</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  </values>
  </multiRef>
  <multiRef id="id5" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns10:SoapFieldValues" xmlns:ns10="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <names soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <names xsi:type="xsd:string">BRD Received</names> 
  <names xsi:type="xsd:string">Dev Started</names> 
  <names xsi:type="xsd:string">EUDA Registered</names> 
  <names xsi:type="xsd:string">Prioritised   Pending Dev</names> 
  <names xsi:type="xsd:string">Product</names> 
  <names xsi:type="xsd:string">Product Group</names> 
  <names xsi:type="xsd:string">Requestor POC</names> 
  <names xsi:type="xsd:string">Signed Off</names> 
  <names xsi:type="xsd:string">UAT Delivered</names> 
  <names xsi:type="xsd:string">UAT Delivery Date</names> 
  <names xsi:type="xsd:string">VP Approval</names> 
  <names xsi:type="xsd:string">BMSC POC</names> 
  <names xsi:type="xsd:string">$fild306322$Coverage</names> 
  <names xsi:type="xsd:string">$fild306551$test</names> 
  </names>
  <types soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  </types>
  <values soapenc:arrayType="xsd:anyType[14]" xsi:type="soapenc:Array">
  <values xsi:type="xsd:dateTime">2013-02-01T08:00:00.000Z</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="soapenc:string">Synthetics</values> 
  <values xsi:type="soapenc:string">GPF</values> 
  <values xsi:type="soapenc:string" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:dateTime">2013-02-01T08:00:00.000Z</values> 
  <values xsi:type="soapenc:string">anon_user</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  </values>
  </multiRef>
  </soapenv:Body>
  </soapenv:Envelope>

所有这些仅代表来自 TeamForge CollabNet 站点的 4 条记录。

我可以看到这样的“结构”。该路径/soapenv:Envelope/soapenv:Body/multiRef/dataRows包含对 4 个奇数格式记录的 4 个引用<dataRows href="#id1" />

然后使用 href id,您可以转到如下路径:

/soapenv:Envelope/soapenv:Body/multiRef (where the id attribute matches the record)

在这个节点上,我希望能够挑选出一些元素,例如“assignedToFullname”、“title”等。

然而,在这个节点中有一个名为“flexFields”的元素,看起来像这样:

<flexFields href="#id6" /> 

这是因为在 CollabNet 中您可以拥有许多自定义字段。因此,遵循与以前相同的规则,弹性域信息位于:

/soapenv:Envelope/soapenv:Body/multiRef (where the id attribute matches the flexfield href)

一条记录的此 XML 的片段如下:

<multiRef id="id7" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:SoapFieldValues" xmlns:ns7="http://schema.open.collab.net/sfee50/soap60/type" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <names soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <names xsi:type="xsd:string">BRD Received</names> 
  <names xsi:type="xsd:string">Dev Started</names> 
  <names xsi:type="xsd:string">EUDA Registered</names> 
  <names xsi:type="xsd:string">Prioritised   Pending Dev</names> 
  <names xsi:type="xsd:string">Product</names> 
  <names xsi:type="xsd:string">Product Group</names> 
  <names xsi:type="xsd:string">Requestor POC</names> 
  <names xsi:type="xsd:string">Signed Off</names> 
  <names xsi:type="xsd:string">UAT Delivered</names> 
  <names xsi:type="xsd:string">UAT Delivery Date</names> 
  <names xsi:type="xsd:string">VP Approval</names> 
  <names xsi:type="xsd:string">BMSC POC</names> 
  <names xsi:type="xsd:string">$fild306322$Coverage</names> 
  <names xsi:type="xsd:string">$fild306551$test</names> 
  </names>
  <types soapenc:arrayType="xsd:string[14]" xsi:type="soapenc:Array">
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">String</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">Date</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  <types xsi:type="xsd:string">User</types> 
  </types>
  <values soapenc:arrayType="xsd:anyType[14]" xsi:type="soapenc:Array">
  <values xsi:type="xsd:dateTime">2013-01-30T08:00:00.000Z</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="soapenc:string">Synthetics</values> 
  <values xsi:type="soapenc:string">GPF</values> 
  <values xsi:type="soapenc:string" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:dateTime">2013-01-30T08:00:00.000Z</values> 
  <values xsi:type="soapenc:string">anon_user</values> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  <values xsi:type="xsd:anyType" xsi:nil="true" /> 
  </values>
  </multiRef>

是否可以以任何方式使用 SQL Server 将其输出到一个表中,其中包含许多指定元素作为列加上fledFields 及其值作为列。

对此的任何帮助将不胜感激。

更新 OK 到目前为止,我已经设法从 XML 文件中获取正常数据,如下所示:

SELECT T.c.value('@id','varchar(5)') as [id]
    , T.c.value('title[1]','varchar(255)') as [Title]
    , T.c.value('id[1]','varchar(255)') as [Artifact]
    , T.c.value('priority[1]','varchar(255)') as [Priority]
    , T.c.value('assignedToFullname[1]','varchar(255)') as [Assignee]
    , T.c.value('status[1]','varchar(255)') as [Status]
    , T.c.value('statusClass[1]','varchar(255)') as [statusClass]
    , T.c.value('folderTitle[1]','varchar(255)') as [Tracker]
    , Replace(T.c.value('flexFields[1]/@href','varchar(255)'),'#','') as [flexFieldsID]
FROM @xml.nodes('declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/";
/soapenv:Envelope[1]/soapenv:Body[1]/multiRef') T(c)
WHERE T.c.value('@id','varchar(5)') IN
    (SELECT Replace(DR.h.value('@href','varchar(5)'),'#','') as [DataRowID]
    FROM @xml.nodes('declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/";
    /soapenv:Envelope[1]/soapenv:Body[1]/multiRef/dataRows/dataRows') DR(h))

但是,这看起来很可怕,我想知道是否有人可能知道更优雅的方式。我还坚持如何将“flexFields”附加到此结果表的末尾。

进一步更新 我想我已经很接近了,但我无法弄清楚如何将 flexFields 放入“平面”表中,因为“名称”和“值”之间没有结构联系,它只是按顺序匹配它的外观,所以第一个名称是第一个值的字段名称,依此类推,我只是不知道如何编写查询来做到这一点。

4

1 回答 1

0

SQL Server 提供了 OPENXML 方法来从 XML 中获取数据,这些数据可以插入到任何表或临时表中。例子:

    DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='
<ROOT>
<Customer CustomerID="VINET" ContactName="Paul Henriot">
   <Order CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00">
      <OrderDetail OrderID="10248" ProductID="11" Quantity="12"/>
      <OrderDetail OrderID="10248" ProductID="42" Quantity="10"/>
   </Order>
</Customer>
<Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">
   <Order CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00">
      <OrderDetail OrderID="10283" ProductID="72" Quantity="3"/>
   </Order>
</Customer>
</ROOT>'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- Execute a SELECT statement that uses the OPENXML rowset provider.
SELECT    *
FROM       OPENXML (@idoc, '/ROOT/Customer',1)
            WITH (CustomerID  varchar(10),
                  ContactName varchar(20))

详细可以参考: OPENXML

我在这种方法中看到的唯一问题是您的示例 XML 有很多用于读取 xml 的转义/无效字符。为此,您必须使用 REPLACE 将中间 PL/SQL 中的 XML 替换为某个有效字符,以便您可以将值从 XML 提取到表中。抱歉,回复不完整,我现在有点忙于提供实际工作查询。希望能帮助到你。

于 2013-02-04T12:15:11.577 回答