declare @xmlData XML='<UICK>
<KEM count="2" change="created">
<Identifier>ZAP46817</Identifier>
<ChangeLevel>1</ChangeLevel>
<Editor>GGV</Editor>
<ReleaseDateTime>2017-06-12T05:40:40</ReleaseDateTime>
<EngineeringScope>2528R ''P'' RELEASE</EngineeringScope>
<Reason>NYLON HOSE E "P" RELEASE FOR NEW ZEALANDMATURITY CHANGE</Reason>
<Status>REFER PROJECT</Status>
<LegalRelevance>no</LegalRelevance>
<SpecialToolsRequirement>N</SpecialToolsRequirement>
<CircularTechnicalLetterAvailability>N</CircularTechnicalLetterAvailability>
<ExaustRelevance>N</ExaustRelevance>
<StopNoticeType>N</StopNoticeType>
<Request>
<Organization>requester</Organization>
<Person>VINOTHKUMA</Person>
<Department>TP/ACI</Department>
<DateTime>2017-06-02T00:00:00</DateTime>
</Request>
<Update>
<Organization>main editor</Organization>
<Person>VINOTHKUMA</Person>
<Department>TP/ACI</Department>
<DateTime>2017-06-02T00:00:00</DateTime>
</Update>
<Approval>
<Organization>approver</Organization>
<Person>RPRABHU</Person>
<Department>TP/ACI</Department>
<DateTime>2017-06-09T00:00:00</DateTime>
</Approval>
<Authorization>
<Organization>authorizer</Organization>
<Person>VJAJI</Person>
<Department>TP/ACI</Department>
<DateTime>2017-06-09T00:00:00</DateTime>
</Authorization>
<ProductDocumentationUpdate>
<Organization>product documentation editor</Organization>
<Person>VIGNEB</Person>
<Department>TP/AIH</Department>
<DateTime>2017-06-06T00:00:00</DateTime>
</ProductDocumentationUpdate>
<Further-1>
<Organization>CONTROLLED BY </Organization>
<Person>SARAVANAN</Person>
<Department>TP/AIH</Department>
</Further-1>
<ProjectIdentifier>DICVPVH-Y17</ProjectIdentifier>
<ProjectName>HDT PROJECT 2017 HDT VEHICLE SERIES 2017</ProjectName>
<ChangeRequestIdentifier>NO CR</ChangeRequestIdentifier>
<TechnicalData>no</TechnicalData>
<Distributor>FQ</Distributor>
<KemType>A</KemType>
<StopNoticeCauseCode>U</StopNoticeCauseCode>
<ChangeCategories>
<Category>
<Identifier>5</Identifier>
<Name>MaturityLevelChange</Name>
</Category>
</ChangeCategories>
<MATERIALMASTERS>
<PART_MATERIALMASTER count="1" change="modified">
<Identifier>A4004204731</Identifier>
<ChangeLevel>3</ChangeLevel>
<UnitOfQuantity>each</UnitOfQuantity>
<EnglishName>ZB COMPRESSED AIR LINE/MB/2528R 6X25700 ABS/TEST CON</EnglishName>
<SpanishName>ZB TUB.P.AIRE COMP / MB/2528R 6X2 5700WB ABS/TEST CON</SpanishName>
<PortugueseName>ZB TBO.AR COMPRIM. / MB/2528R 6X2 5700WB ABS/TEST CON</PortugueseName>
<FrenchName>ZB COND AIR COMPR / MB/2528R 6X2 5700WB ABS/TEST CON</FrenchName>
<DrawingGeometryChangeLevel>1</DrawingGeometryChangeLevel>
<SecurityRelevance>N</SecurityRelevance>
<CertificationRelevance>N</CertificationRelevance>
<PartsListElementType>assembly</PartsListElementType>
<ReferenceDrawingType>06.04.2017</ReferenceDrawingType>
<CADIdType>G</CADIdType>
<FlashwareDocumentationRelevantPart>no</FlashwareDocumentationRelevantPart>
<TheftRelevantPart>no</TheftRelevantPart>
<ReleaseItemType>SERIE</ReleaseItemType>
<ReleaseDesignChangeOrder>ZAP46817</ReleaseDesignChangeOrder>
<LeadingDocumentationGroup>KH</LeadingDocumentationGroup>
<SharedPartFlag>no</SharedPartFlag>
<ChangeText>MATURITY CHANGE</ChangeText>
<TermID>0500002680</TermID>
<RSK>
<RSK-NL>LUCHTDRUKLEIDING</RSK-NL>
<RSK-PL>PRZEWOD SPREZ. POW.</RSK-PL>
<RSK-DA>TRYKLUFTROER</RSK-DA>
<RSK-FR>CONDUITE DAIR COMPRIME</RSK-FR>
<RSK-HU>SURITETTLEVEGOVEZETEK</RSK-HU>
<RSK-TR>BASINCLI HAVA HATTI</RSK-TR>
<RSK-CS>POTRUBI TLAKOVZDUSNE</RSK-CS>
<RSK-DE>DRUCKLUFTLTG.</RSK-DE>
<RSK-SV>TRYCKLUFTSLEDNING</RSK-SV>
<RSK-SK>VEDENIE VZDUCHU</RSK-SK>
<RSK-EN>COMPRESSED AIR LINE</RSK-EN>
<RSK-ES>TUBERIA</RSK-ES>
<RSK-IT>TUBAZIONE PNEUMATICA</RSK-IT>
<RSK-PT>TUBO DO AR COMPRIMIDO</RSK-PT>
<RSK-BG>??????????? ?????.????.</RSK-BG>
<RSK-RU>????????????</RSK-RU>
<RSK-ZH>??????</RSK-ZH>
</RSK>
</PART_MATERIALMASTER>
<PART_MATERIALMASTER count="2" change="modified">
<Identifier>A4004209329</Identifier>
<ChangeLevel>3</ChangeLevel>
<UnitOfQuantity>each</UnitOfQuantity>
<EnglishName>ZB COMPRESSED AIR LINE/ACC 6X2 5700W/G131/BS4/PTO/RHD</EnglishName>
<SpanishName>ZB TUB.P.AIRE COMP / ACC 6X2 5700WB/BS4/PTO/RHD</SpanishName>
<PortugueseName>ZB TUBO DO AR COMPRIMIDO / ACC 6X2 5700WB/BS4/PTO/RHD</PortugueseName>
<FrenchName>ZB CONDUITE AIR COMPRIME / ACC 6X2 5700WB/BS4/PTO/RHD</FrenchName>
<DrawingGeometryChangeLevel>1</DrawingGeometryChangeLevel>
<SecurityRelevance>N</SecurityRelevance>
<CertificationRelevance>N</CertificationRelevance>
<PartsListElementType>assembly</PartsListElementType>
<ReferenceDrawingType>07.04.2017</ReferenceDrawingType>
<CADIdType>G</CADIdType>
<FlashwareDocumentationRelevantPart>no</FlashwareDocumentationRelevantPart>
<TheftRelevantPart>no</TheftRelevantPart>
<ReleaseItemType>SERIE</ReleaseItemType>
<ReleaseDesignChangeOrder>ZAP46817</ReleaseDesignChangeOrder>
<LeadingDocumentationGroup>KH</LeadingDocumentationGroup>
<SharedPartFlag>no</SharedPartFlag>
<ChangeText>MATURITY CHANGE</ChangeText>
<TermID>0500002680</TermID>
<RSK>
<RSK-NL>LUCHTDRUKLEIDING</RSK-NL>
<RSK-PL>PRZEWOD SPREZ. POW.</RSK-PL>
<RSK-DA>TRYKLUFTROER</RSK-DA>
<RSK-FR>CONDUITE DAIR COMPRIME</RSK-FR>
<RSK-HU>SURITETTLEVEGOVEZETEK</RSK-HU>
<RSK-TR>BASINCLI HAVA HATTI</RSK-TR>
<RSK-CS>POTRUBI TLAKOVZDUSNE</RSK-CS>
<RSK-DE>DRUCKLUFTLTG.</RSK-DE>
<RSK-SV>TRYCKLUFTSLEDNING</RSK-SV>
<RSK-SK>VEDENIE VZDUCHU</RSK-SK>
<RSK-EN>COMPRESSED AIR LINE</RSK-EN>
<RSK-ES>TUBERIA</RSK-ES>
<RSK-IT>TUBAZIONE PNEUMATICA</RSK-IT>
<RSK-PT>TUBO DO AR COMPRIMIDO</RSK-PT>
<RSK-BG>??????????? ?????.????.</RSK-BG>
<RSK-RU>????????????</RSK-RU>
<RSK-ZH>??????</RSK-ZH>
</RSK>
</PART_MATERIALMASTER>
</MATERIALMASTERS>
<BOMMASTERS>
<LOWER_BOM_HEADER count="1" change="modified">
<ParentBomElement>A4004204731</ParentBomElement>
<BomPosition change="deleted">
<BomElement>A4004291808</BomElement>
<Position>000010</Position>
<Quantity>1</Quantity>
<UnitOfQuantity>each</UnitOfQuantity>
<MaturityLevel>V</MaturityLevel>
<Plant>FQ, D, FH, FR, U, UD, Z</Plant>
<ReleaseDesignChangeOrder>ZAP718915</ReleaseDesignChangeOrder>
</BomPosition>
<BomPosition change="created">
<BomElement>A4004291808</BomElement>
<Position>000010</Position>
<Quantity>1</Quantity>
<UnitOfQuantity>each</UnitOfQuantity>
<MaturityLevel>P</MaturityLevel>
<Plant>FQ, FH</Plant>
<ReleaseDesignChangeOrder>ZAP46817</ReleaseDesignChangeOrder>
</BomPosition>
</LOWER_BOM_HEADER>
<LOWER_BOM_HEADER count="2" change="modified">
<ParentBomElement>Z40086626</ParentBomElement>
<BomPosition change="deleted">
<BomElement>A4004209329</BomElement>
<Position>000100</Position>
<Quantity>1</Quantity>
<UnitOfQuantity>each</UnitOfQuantity>
<MaturityLevel>V</MaturityLevel>
<Plant>FQ, FR, U, UM, DW, J, SR, TD, TY, Z, EK, ZV</Plant>
<ReleaseDesignChangeOrder>ZAP31815</ReleaseDesignChangeOrder>
</BomPosition>
<BomPosition change="created">
<BomElement>A4004209329</BomElement>
<Position>000100</Position>
<Quantity>1</Quantity>
<UnitOfQuantity>each</UnitOfQuantity>
<MaturityLevel>P</MaturityLevel>
<Plant>FQ, FH</Plant>
<ReleaseDesignChangeOrder>ZAP46817</ReleaseDesignChangeOrder>
</BomPosition>
</LOWER_BOM_HEADER>
<LOWER_BOM_HEADER count="3" change="modified">
<ParentBomElement>A4004209329</ParentBomElement>
<BomPosition change="deleted">
<BomElement>A4004296901</BomElement>
<Position>000100</Position>
<Quantity>1</Quantity>
<UnitOfQuantity>each</UnitOfQuantity>
<MaturityLevel>V</MaturityLevel>
<Plant>FQ, FR, U, UM, DW, J, SR, TD, TY, Z, EK, ZV</Plant>
<ReleaseDesignChangeOrder>ZAP31815</ReleaseDesignChangeOrder>
</BomPosition>
<BomPosition change="created">
<BomElement>A4004296901</BomElement>
<Position>000100</Position>
<Quantity>1</Quantity>
<UnitOfQuantity>each</UnitOfQuantity>
<MaturityLevel>P</MaturityLevel>
<Plant>FQ, FH</Plant>
<ReleaseDesignChangeOrder>ZAP46817</ReleaseDesignChangeOrder>
</BomPosition>
</LOWER_BOM_HEADER>
<LOWER_BOM_HEADER count="4" change="modified">
<ParentBomElement>Z40086699</ParentBomElement>
<BomPosition change="deleted">
<BomElement>A4004204731</BomElement>
<Position>000100</Position>
<Quantity>1</Quantity>
<UnitOfQuantity>each</UnitOfQuantity>
<MaturityLevel>V</MaturityLevel>
<Plant>FQ, D, FH, FR, U, UD, Z</Plant>
<ReleaseDesignChangeOrder>ZAP718915</ReleaseDesignChangeOrder>
</BomPosition>
<BomPosition change="created">
<BomElement>A4004204731</BomElement>
<Position>000100</Position>
<Quantity>1</Quantity>
<UnitOfQuantity>each</UnitOfQuantity>
<MaturityLevel>P</MaturityLevel>
<Plant>FQ, FH</Plant>
<ReleaseDesignChangeOrder>ZAP46817</ReleaseDesignChangeOrder>
</BomPosition>
</LOWER_BOM_HEADER>
<UPPER_BOM_HEADER count="5" change="modified">
<ModelVariant>F400216220D130390</ModelVariant>
<BomPosition change="deleted">
<Group>S429</Group>
<Scope>SN42240</Scope>
<Position>000280</Position>
<BomElement>Z40086626</BomElement>
<Quantity>1</Quantity>
<MaturityLevel>T</MaturityLevel>
</BomPosition>
<BomPosition change="deleted">
<Group>S429</Group>
<Scope>SN42240</Scope>
<Position>000300</Position>
<BomElement>Z40086699</BomElement>
<Quantity>1</Quantity>
<MaturityLevel>T</MaturityLevel>
</BomPosition>
<BomPosition change="created">
<Group>S429</Group>
<Scope>SN42240</Scope>
<Position>000280</Position>
<BomElement>Z40086626</BomElement>
<Quantity>1</Quantity>
<MaturityLevel>P</MaturityLevel>
</BomPosition>
<BomPosition change="created">
<Group>S429</Group>
<Scope>SN42240</Scope>
<Position>000300</Position>
<BomElement>Z40086699</BomElement>
<Quantity>1</Quantity>
<MaturityLevel>P</MaturityLevel>
</BomPosition>
</UPPER_BOM_HEADER>
</BOMMASTERS>
</KEM>
</UICK>'
我正在使用以下代码来获取数据,但它没有正确显示。 它应该显示 - &gt;在内部标记一个标识符值,然后在BOMPosition节点内的UPPER_BOM_HEADER和BomElement值内的多个ModelVariant值。确切地说,应该是根据以下URL。 父节点现在包含一个,它可以包含更多数量的节点,如上面的详细信息。
SELECT doc.col.value('(/ UICK / KEM/Identifier/text())[1]','VARCHAR(100)') Identifier,doc.col.value('(/ UICK / KEM/BOMMASTERS / UPPER_BOM_HEADER/ModelVariant/text())[1]','VARCHAR(100)') ModelVariant,doc.col.value('(/ UICK / KEM/BOMMASTERS / UPPER_BOM_HEADER / BomPosition/BomElement/text())[1]','VARCHAR(100)') BomElement FROM @xmlData.nodes('/ UICK / KEM/*') doc(col)
答案 0 :(得分:1)
你的问题还不清楚......下次请尝试减少!!! 你的样本数据到所需的最低要求,看看你需要什么,请提供预期的输出强>
我的神奇晶球告诉我,你可能正在寻找这样的东西:
SELECT @xmlData.value('(/UICK/KEM/Identifier/text())[1]','NVARCHAR(100)') Identifier
,u_bom.value('(ModelVariant/text())[1]','VARCHAR(100)') ModelVariant
,bomP.value('(BomElement/text())[1]','VARCHAR(100)') BomElement
FROM @xmlData.nodes('/UICK/KEM/BOMMASTERS/UPPER_BOM_HEADER') A(u_bom)
CROSS APPLY u_bom.nodes('BomPosition') AS B(bomP)
<KEM>
(提示请避免变色龙问题!)
试试这样:
SELECT kem.value('(Identifier/text())[1]','NVARCHAR(100)') Identifier
,u_bom.value('(ModelVariant/text())[1]','VARCHAR(100)') ModelVariant
,bomP.value('(BomElement/text())[1]','VARCHAR(100)') BomElement
FROM @xmlData.nodes('/UICK/KEM') AS A(kem)
CROSS APPLY kem.nodes('BOMMASTERS/UPPER_BOM_HEADER') B(u_bom)
CROSS APPLY u_bom.nodes('BomPosition') AS C(bomP)