Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I've tried using the code below:<?xml version="1.0" encoding="utf-8"?> <install type="module" version="1.0.0"> <name>TEST</name> <desription>This is a test</desription> <notebook_tabs> <tab index="1">Create <button internal_name="test1" parent="-1" text="button 1" x_coordinate="5" y_coordinate="5" x_size="-1" y_size="-1" evt_1="EVT_BUTTON" evt_1_function="testclick" /> <button internal_name="test2" parent="-1" text="button 2" x_coordinate="50" y_coordinate="50" x_size="-1" y_size="-1" evt_1="EVT_BUTTON" evt_1_function="testclick2" /> </tab> <tab index="2">Assign</tab> </notebook_tabs> </install>
but all I get is the entire XML data, what am I doing wrong?use strict; use warnings; use XML::Twig; use Data::Dumper; my $xfile = <<EOF; <?xml version="1.0" encoding="utf-8"?> <install type="module" version="1.0.0"> <name>TEST</name> <desription>This is a test</desription> <notebook_tabs> <tab index="1">Create <button internal_name="test1" parent="-1" text="button 1" x_coordinate="5" y_coordinate="5" x_size="-1" y_size="-1" evt_1="EVT_BUTTON" evt_1_function="testclick" /> <button internal_name="test2" parent="-1" text="button 2" x_coordinate="50" y_coordinate="50" x_size="-1" y_size="-1" evt_1="EVT_BUTTON" evt_1_function="testclick2" /> </tab> <tab index="2">Assign</tab> </notebook_tabs> </install> EOF my $t= new XML::Twig(); $t->parse($xfile); my $install = $t->root(); print "NAME: " . $install->first_child('name') . "\n"; }
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: One more XML Question
by toolic (Bishop) on Oct 08, 2008 at 19:30 UTC | |
by Anonymous Monk on Oct 08, 2008 at 19:33 UTC |