Tworec has asked for the wisdom of the Perl Monks concerning the following question:
Hello folks!
Do you know XML::easytree? It's really good tool, but unfortunately I am a perl newbie and I can't get the content of the $tree out for my other purposes. I am really depressed, for last 4 days I couldn't come up with my own idea and the only example of what I want to do next I found is some kind of broken or what.
See:#!/usr/bin/perl -w #use strict; use XML::Parser; use XML::Parser::EasyTree; use Data::Dumper; my $p=new XML::Parser(Style=>'EasyTree'); my $tree=$p->parsefile("test.xml"); #my $element; print_easy_tree($tree); sub print_easy_tree { my $node = shift; { if ($element->{type} eq 'e') { print "<$element->{name}>"; print_easy_tree($element->{content}); print "</$element->{name}>"; } elsif ($element->{type} eq 't') { print $element->{content}; } else { print "[IGNORED $element->{type}]"; } } }
When I try to run this code, I get error that $element is not initialized. I tried to repair it, but I don't know where and what. Please help poor stupid student monk and end his torture.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to get content of an XML::easytree output
by kcott (Archbishop) on Mar 07, 2013 at 23:49 UTC | |
by tobyink (Canon) on Mar 08, 2013 at 06:44 UTC | |
by kcott (Archbishop) on Mar 08, 2013 at 08:22 UTC | |
by Tworec (Initiate) on Mar 08, 2013 at 08:52 UTC | |
by kcott (Archbishop) on Mar 08, 2013 at 09:07 UTC | |
by Tworec (Initiate) on Mar 08, 2013 at 09:39 UTC | |
by kcott (Archbishop) on Mar 08, 2013 at 12:22 UTC | |
Re: How to get content of an XML::easytree output
by Anonymous Monk on Mar 07, 2013 at 23:42 UTC |
Back to
Seekers of Perl Wisdom