Thread xml to txt (6 answers)
Opened by fraggs at 2006-09-11 13:09

fraggs
 2006-09-11 13:09
#69656 #69656
User since
2006-09-11
179 Artikel
BenutzerIn
[Homepage] [default_avatar]
hallo perl community,

nachdem ihr mir so super geholfen habt mit der txt eingabe in eine datei haette ich noch eine weitere Frage.

Nur wuerde ich gerne eine XML datei lesen und dann diese in eine txt datei schreiben. ich ist was ich schon geschrieben habe

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!perl 
#perl write test 2 w/ xml
use strict;
use warnings;

use XML::Simple;
use Data::Dumper;

# xml creation
$xml = new XML::Simple;

# read XML file
$data = $xml->XMLin("data2.xml");

# creating the txt file
my $data_file = 'h:\\xmlreadingperl\data.txt';

# write directly to the file
open( FILE, ">", $data_file ) or die $!;

print FILE Dumper($data); # printing the final stuff to txt file

close(FILE);


das problem:
Quote
h:\XMLReadingPerl>perl perlwrite.pl
Global symbol "$xml" requires explicit package name at perlwrite.pl line 10.
Global symbol "$data" requires explicit package name at perlwrite.pl line 13.
Global symbol "$xml" requires explicit package name at perlwrite.pl line 13.
Global symbol "$data" requires explicit package name at perlwrite.pl line 21.
Execution of perlwrite.pl aborted due to compilation errors.


data2.xml ist einfach eine generische xml datei. vielleicht muss ich die xml datei erst einlesen via open und dann kann ich sie abspeichern in eine txt datei ?

danke
mmm twix

View full thread xml to txt