in reply to XML::Twig output with delimiter

#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; my $xml = <<'__XML__'; <root> <record> <id>1</id> <sched>QWERTY</sched> <filePath>D:/Book1.xls</filePath> <fString>bata</fString> </record> <record> <id>2</id> <sched>PANAMA</sched> <filePath>C:/test.doc</filePath> <fString>vata</fString> </record> </root> __XML__ my $t= XML::Twig->new(); $t->parse($xml); my $root= $t->root; my @para= $root->children(); # get the root's children foreach my $para (@para) { for my $pan( $para->children ){ print $pan->text, "\n"; } print $para->_dump(), "\n"; } __END__
1 QWERTY D:/Book1.xls bata | |-record | | |-id | | | |-PCDATA: '1' | | |-sched | | | |-PCDATA: 'QWERTY' | | |-filePath | | | |-PCDATA: 'D:/Book1.xls' | | |-fString | | | |-PCDATA: 'bata' 2 PANAMA C:/test.doc vata | |-record | | |-id | | | |-PCDATA: '2' | | |-sched | | | |-PCDATA: 'PANAMA' | | |-filePath | | | |-PCDATA: 'C:/test.doc' | | |-fString | | | |-PCDATA: 'vata'

Replies are listed 'Best First'.
Re^2: XML::Twig output with delimiter
by pankaj_it09 (Scribe) on Dec 09, 2008 at 12:06 UTC
    In the code can I do like this :

    $content = print $pan->text, "\n";

    Actually I did like that but no data is coming in variable $content.
      Either you're a troll, or you need to read perlintro
        Please tell me how to do ?