As mentioned by Edan, I think XML::Twig is an excellent option for this kind of thing.
Below i have given some code which may u can modify for ur needs.
The below code will create three files named as per dc:identifier element.
For Further details see XML::Twig.
use XML::Twig; undef $/; $x=<DATA>; ## i have assumed that dc:identifier as first child of rdf:Description +. $p=new XML::Twig(twig_roots=>{ 'rdf:Description'=>\&rdf}, pretty_print => 'indented'); $p->parse($x); sub rdf { my ($a,$b)=@_; my $filename=$b->first_child_text; open(FOUT,">$filename") or die("$filename not opened for writing\n +"); print FOUT q(<?xml version="1.0" encoding="UTF-8"?>); print FOUT $b->sprint; close(FOUT); } __DATA__ <?xml version="1.0" encoding="UTF-8"?> <ab:root> <rdf:Description> <dc:identifier>ab.xml</dc:identifier> <dc:abc>abc</dc:abc> </rdf:Description> <rdf:Description> <dc:identifier>bc.xml</dc:identifier> <dc:abc>bcd</dc:abc> </rdf:Description> <rdf:Description> <dc:identifier>ef.xml</dc:identifier> <dc:abc>efg</dc:abc> </rdf:Description> </ab:root>
In reply to Re: Script to Parse 1 large xml file to many smaller files
by murugu
in thread Script to Parse 1 large xml file to many smaller files
by LF
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |