Hello everyone!

It's my first expirience with XML.

I have simple XML document like this
<?xml version="1.0"?>
<site>
  <section id='1'>
    <page id='11' />
  </section>
  <page id='00' />
  <section id='2'>
    <page id='22' />
      <section id='3'>
        <page id='33' />
      </section>
  </section>
  <page id='44' />
</site>

And I need to produce something like this

========================================
...... something like header here ......
........ root is 'site' ................

'section', id=1 (parent = 'site')
'page', id=11 (parent = 'section', id=1)
'page', id=00 (parent = 'site')
'section', id=2 (parent = 'site')
'page', id=22 (parent = 'section', id=2)
'section', id=3 (parent = 'section', id=2)
'page', id=33 (parent = 'section', id=3)

...... something like footer here ......
........................................
========================================

How can I do it with siplest way?


I've been trying to make this with XML::Parser::Expat,
my $parser = new XML::Parser::Expat;
$parser->setHandlers(Start => \&start);
$parser->parsefile($file);

sub start {
  my ($p, $el, %atts) = @_;
  print "'$el', id=$atts{id} (parent = $current_element, id=????";
}

But in this case I can't know attributes of parent node... How can I know
this?
May be there are another better ways to solve my problem?

Many many thanks for your attention!!!




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to