<p>The manual page for <code>XML::Parser::Style::Objects</code> is horrible.  A simple hello world style program would really be helpful.</p>

<p>I really wanted to do something like this: (not real code of course)</p>

<pre><code>use XML::Parser;
my $p = XML::Parser-&gt;new(Style =&gt; 'Objects', Pkg =&gt; 'MyNode');
my $tree = $p-&gt;parsefile('foo.xml');
$tree-&gt;doSomething();

MyNode::doSomething() {
  my $self = shift;
  print "This is a normal node";
  for $kid ($self-&gt;Kids)
  {
    $kid-&gt;doSomething();
  }
}

MyNode::special::doSomething() {
  my $self = shift;
  print "This is a special node";
}
</code></pre>

[{'answer_id': 35450, 'author': 'Pat', 'author_id': 238, 'author_profile': 'https://Stackoverflow.com/users/238', 'pm_score': 2, 'selected': False, 'text': '<p>When ever I need to do something similar, usually I end up using <a href="http://search.cpan.org/~ebohlman/XML-Parser-EasyTree-0.01/EasyTree.pm" rel="nofollow noreferrer">XML::Parser::EasyTree </a> it has better documentation and is simpler to use.</p>\n\n<p>I highly recommend it.</p>\n'}, {'answer_id': 35467, 'author': 'Pat', 'author_id': 238, 'author_profile': 'https://Stackoverflow.com/users/238', 'pm_score': 2, 'selected': True, 'text': '<p>In all cases here is actual code that runs ... doesn\'t mean much but produces output and hopefully can get you started ...</p>\n\n<pre><code>use XML::Parser;\n\npackage MyNode::inner;\n    sub doSomething {\n      my $self = shift;\n      print "This is an inner node containing : ";\n      print $self-&gt;{Kids}-&gt;[0]-&gt;{Text};\n      print "\\n";\n    }\npackage MyNode::Characters;\n    sub doSomething {}\npackage MyNode::foo;\n    sub doSomething {\n      my $self = shift;\n      print "This is an external node\\n";\n      for $kid (@ { $self-&gt;{Kids} }) {\n        $kid-&gt;doSomething();\n      }\n    }\n\npackage main;\n\nmy $p = XML::Parser-&gt;new(Style =&gt; \'Objects\', Pkg =&gt; \'MyNode\');\nmy $tree = $p-&gt;parsefile(\'foo.xml\');\nfor (@$tree) {\n    $_-&gt;doSomething();\n}\n</code></pre>\n\n<p>with foo.xml</p>\n\n<pre><code> &lt;foo&gt; &lt;inner&gt;some text&lt;/inner&gt; &lt;inner&gt;something else&lt;/inner&gt;&lt;/foo&gt;\n</code></pre>\n\n<p>which outputs</p>\n\n<pre><code>&gt;perl -w "tree.pl"     \nThis is an external node\nThis is an inner node containing : some text\nThis is an inner node containing : something else\n</code></pre>\n\n<p>Hope that helps.</p>\n'}]
['https://Stackoverflow.com/questions/34914', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3657/']