Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> XML generation in Pig


Copy link to this message
-
Re: XML generation in Pig
You could write a UDF that take the tuple and does string munging to
produce the XML for a given record. Each <stud> element would be on a
single line if that's ok.

This is approach is ugly in that you're manually building XML strings in
Java, but it's quick and easy to implement.
On Tue, May 8, 2012 at 10:53 AM, DIPESH KUMAR SINGH
<[EMAIL PROTECTED]>wrote:

> Hi,
>
> I have data in a file which has schema, say like this: (stud_id, Physics,
> Chemistry, Bio, CS)
>
> I need to generate an output which should contain (stud_id , xml_payload)
> for each record in my relation.
>
> The type of dynamic xml i need to generate is like this:
>
> <stud xmlns: www.w3.org .... ... >
>   <stud_id> A-12 </stud_id>
>   <subjects>
>         <marks>
>               <phy> 98 </phy>
>               <chem>96 </chem>
>        </marks>
>   </subjects>
> </stud>
>
> <stud xmlns: www.w3.org .... >
>   <stud_id> A-102 </stud_id>
>   <subjects>
>         <marks>
>               <phy> 98 </phy>
>               <chem>96 </chem>
>               <CS> 100</CS>
>        </marks>
>   </subjects>
> </stud>
>
> Any suggestions on how to proceed on this? I am bit new to pig.
>
> Thanks & Regards,
>
> Dipesh
>

--
*Note that I'm no longer using my Yahoo! email address. Please email me at
[EMAIL PROTECTED] going forward.*
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB