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.
In reply to How to get content of an XML::easytree output by Tworec
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |