How can we convert XML file to CSV?

后端 未结 6 591
星月不相逢
星月不相逢 2021-01-29 09:05

I am having an XML file



    
        
        

        
6条回答
  •  难免孤独
    2021-01-29 09:55

    Use the straightforward SAX API via the standard Java JAXP package. This will allow you to write a class that receives events for each XML element your reader encounters.

    Briefly:

    1. read your XML in using SAX
    2. record text values via the SAX DefaultHandler characters() method
    3. when you get an end event for a COL, record this string value
    4. when you get the ROW end event, simply write out a comma separated line of previously recorded values

提交回复
热议问题