load xml file into snowflake : external stage

Viewed 36

i need to load XML file into snowflake which is nested in many ways ,sample as below, i have loaded it in table with VARIANT datatype which comes as a XML format.

how to convert XML into table format and load .

<Request>
    <PRODUCT>
        <Address>true</Address>
        <Age>true</Age>
        <ChildDOB>true</ChildDOB>
        <ChildName>true</ChildName>
        <ClaimNumber>true</ClaimNumber>
        <DOB>true</DOB>
        <GroupNumber>true</GroupNumber>
        
    </PRODUCT>

    <Attachments>
        <DocID>823E087C-45CD-8659</DocID>
        <DocName>DC Batch Number</DocName>
    </Attachments>
    <Index>
        
        <Date>20220728T164027.000 GMT</Date>
        <Code>1</Code>
        <DCReceivedDate>20220728T164027.000 GMT</DCReceivedDate>
        <RouteTo>ROUTE ENGINE</RouteTo>
        <XMLDocument>
            <document>
                <templateID>X999998</templateID>
                <docID>01WBP0T2L806WBMB1........20220616</docID>
                <guid>6AF0FE72-6328-4EBB-92CC-B27870E454F2</guid>
                <docclass>WEES</docclass>
                <form>
                    <date>06/15/2022</date>
                    <call>WEESS</call>
                    <sheetNumber></sheetNumber>
                </form>
                <detail>
                    <rejectDesc />
                    <rejectStatus>100</rejectStatus>
                    <claimant>
                        <firstName>LO</firstName>
                        <middleInitial></middleInitial>
                        <lastName>BA</lastName>
                        <birthDate>03/27/1968</birthDate>
                        <male></male>
                        <female>1</female>
                        <primaryPolicyHolder>1</primaryPolicyHolder>
                        <spouse />
                        <dependant />
                        <fullTimeStudent />
                        <signature>Y</signature>
                    </claimant>
                    <patient>
                        <firstName>LO</firstName>
                        <middleInitial></middleInitial>
                        <lastName>BA</lastName>
                        <birthDate>03/27/1968</birthDate>
                        <male></male>
                        <female>1</female>
                        <primaryPolicyHolder>1</primaryPolicyHolder>
                        <spouse></spouse>
                        <dependant></dependant>
                        <fullTimeStudent></fullTimeStudent>
                        <signature>Y</signature>
                    </patient>
                    <workMissed days="0" />
                </detail>`enter code here`
            </document>
        </XMLDocument>
    </Index>
</Request>

please advise how to use select statement in snowflake to get this code into table.

0 Answers
Related