Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^3: XML::Twig Help

by AndyZaft (Hermit)
on Jul 06, 2010 at 16:17 UTC ( [id://848264] : note . print w/replies, xml ) Need Help??

in reply to Re^2: XML::Twig Help
in thread XML::Twig Help

Well, before we go further, Twig will tell you that it is not well-formed, likely because  <\c> is not a valig tag. If your XML is filled with tags like that even if you manage to open the files themselves you will run into problems.

From your code I assume you are trying to type in a few XML filenames and the process them. First problem, if you only have 1 XML as a test, you need to open fields[0], otherwise open will fail with uninitialized value. Then once you fix that you are trying to open a file that's named the first line of the first file. You also don't need to open a file for XML::Twig, the module can do it itself. I would suggest starting simple, like take 1 XML file and create a simple perl script that opens it and does something with it. Something along the lines of:

#!/usr/bin/perl use strict; use warnings; use XML::Twig; my $file = "yourxmlfilename.xml"; my $t= XML::Twig->new( twig_roots => { 'djn-geo' => 1}); $t->parsefile($file); $t->print;
Based on more assumptions looking at your code that you are trying to output to the second file given in the input, you can redirect later or at command line. Although I'm not sure how that behaves on windows nowadays. In any case you can also use  $t->print_to_file($anotherfilename) and many other ways.