#!/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'
In reply to Re: XML::Twig output with delimiter
by Anonymous Monk
in thread XML::Twig output with delimiter
by pankaj_it09
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |