none
Not displaying all element in XML extractor in U-Sql

    Question

  • I am new to U-Sql and trying to extract xml element. Here is my XML code.
    <Dispositions> <Disposition>test 1</Disposition> <Disposition> test 2</Disposition> </Dispositions>

    Trying to display all "Disposition" values. But final output displaying "Test 2" only. I have <g class="gr_ gr_14 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="14" id="14">code</g> as below.

    `DECLARE @testfile string ="Marlboro20180301000000_child.xml";
    @xmlelementrowpath= EXTRACT Disposition string
    FROM @testfile
    USING new Microsoft.Analytics.Samples.Formats.Xml.XmlExtractor("Dispositions",
    new SQL.MAP<string,string>{
    {"Disposition","Disposition"}
    }
    );

    @words =
    SELECT Ar.word, COUNT(*) AS count
    FROM @xmlelementrowpath
    CROSS APPLY
    EXPLODE(new SQL.ARRAY( Disposition.Split(','))) AS Ar(word)
    GROUP BY Ar.word;
    //ORDER BY count DESC;
    OUTPUT @words
    TO "test.csv"
    USING Outputters.Csv();`

    Correct me about my mistakes.

    Thanks
    Lalith
    Monday, May 7, 2018 2:51 PM

Answers

  • Got Answer here.

    https://stackoverflow.com/questions/50212246/print-all-element-in-xml-extractor-in-u-sql

    • Marked as answer by kirank.gutthi Tuesday, May 8, 2018 10:11 AM
    Tuesday, May 8, 2018 10:11 AM