I am using cloudera Hadoop 2.6, pig 0.15 versions.
I am trying to extract data from xml file. Below you can see part of xml file.
<product productID="MICROLITEMX1600LAMP">
<basicInfo>
<category lang="NL" id="OT1006">Output Accessoires</category>
</basicInfo>
</product>
I can dump node values but not attribute values using XPath() function. You can see the code below which is returning empty tuples instead of productID.
DEFINE XPath org.apache.pig.piggybank.evaluation.xml.XPath();
allProducts = LOAD '/pathtofile/sample.xml' USING org.apache.pig.piggybank.storage.XMLLoader('product') AS (data:chararray);
productsOneByOne = FOREACH allProducts GENERATE XPath(data, 'product/@productID') AS productid:chararray
dump productsOneByOne;
Please help me out to resolve this issue.