Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: XML::Twig Help

by AndyZaft (Hermit)
on Jul 06, 2010 at 16:17 UTC ( #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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://848264]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2018-06-23 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (125 votes). Check out past polls.

    Notices?