如何在配置单元中处理 XML 文件

How to handle XML file in hive

如何在 hive 中处理这个 XML 文件,我只希望在输出中使用 USERNAME 和 PASSWORD

<?XML version=’1.0′ ?>
<DATA>
    <USER USERNAME="ABC" FIRSTNAME="RAJ" LASTNAME="KUMAR" PASSWORD="123" />
    <USER USERNAME="DEF" FIRSTNAME="VENKAT" LASTNAME="BALAJI" PASSWORD="123" />
</DATA>
CREATE TABLE user_xml(USERNAME string,PASSWORD string)
    ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
    WITH SERDEPROPERTIES ( 
        "column.xpath.USERNAME"="/DATA/USER/USERNAME/text()",
        "column.xpath.PASSWORD"="/DATA/USER/PASSWORD/text()"
    ) STORED AS
        INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
        OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
        TBLPROPERTIES ("xmlinput.start"="<DATA","xmlinput.end"="</DATA>");

终于有输出了,请参考https://community.hortonworks.com/articles/972/hive-and-xml-pasring.html