Dear Learner,

We hope you are doing good.

I would request you to use the XMLloader.jar to read the XML file. Please download the same from the below link:

Suppose we have input data as:


Now we can read the XML data using the below commands after going in the grunt shell:

register /home/edureka/Desktop/XMLloader.jar;
pigdata = load '/xml1.xml' USING XMLLoader('name') as (doc:chararray);
values = foreach pigdata GENERATE FLATTEN(REGEX_EXTRACT_ALL(doc,'<name>(.*)</name>')) AS (name:chararray);
dump values;
Please refer to the below screen shot of the output which we are getting at our end:


Please try this and let us know if you face any issue.

I will wait for your response.