Thanks a lot for immediate response.i was able to produce a flat file by using XML::Simple and a small piece of code ,but the xml file comes with fields which are neither in order nor consistent, meaning not every field will come in all child records so my flat file is of no use as i donno where a particular field comes one more thing is : my $t= XML::Twig->new( # the twig will include just the root and selected titles twig_roots => { 'title' => &print_n_purge,} ); sub print_n_pu rge { my( $t, $elt)= _; print $elt->text ; # print the text (including
sub-element texts) print"n"; $t->purge; # frees the memory }
This code is able to print all values record wise but is there any option to separate the values with some delimiter and sort them before printing in this twig_roots or any other code.. im not familiar with these packages..any reference with good num of exampleswould also be helpful Thanks in advance Shlomi Fish <shlomif iglu.org.il> wrote: Hi!
On Saturday 03 February 2007 14:22, vikram veer wrote: > hi all, > I have the following tasks to do in PERL >
First of all see:
http://www.perl.org.il/misc.html#pl_vs_pl
> 1)xml file to flat
file(only values not tags) where i can distinguish > between attribute values and tag values > > 2)Extract and print tags alone and number of times each field has occured > > is there any package which can do this for me ..If so please suggest me a > place where i can get simple examples. >
There are many packages that can do this. I recommend XML::LibXML:
http://search.cpan.org/dist/XML-LibXML/
It has both a DOM/XPath and a SAX interface. You can use the DOM unless the files you're processing are extremely large and won't fit inside your computer's memory at once. If not, use SAX, which is an event-based parser.
Regards,
Shlomi Fish
--------------------------------------------------------------------- Shlomi Fish shlomif iglu.org.il Homepage: http://www.shlomifish.org/
Chuck Norris wrote a complete Perl 6 implementation in a day but then destroyed all evidence with
his bare hands, so no one will know his secrets.
Here’s a new way to find what you're looking for - Yahoo! Answers
|