Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: XML::Twig output with delimiter

by balakrishnan (Monk)
on Dec 09, 2008 at 13:12 UTC ( #729154=note: print w/ replies, xml ) Need Help??


in reply to XML::Twig output with delimiter

I think ,this would help you to get your need,

my $t= XML::Twig->new( twig_handlers => { '_all_' => sub { $_[1]->suffix( " ");}} ); $t->parsefile("new.xml"); my $root= $t->root; my @para= $root->children(); # get the root's children foreach my $para (@para) { print $para->text()."\n"; }


Comment on Re: XML::Twig output with delimiter
Download Code
Re^2: XML::Twig output with delimiter
by pankaj_it09 (Scribe) on Dec 10, 2008 at 06:17 UTC
    Yes it solved the problem to some extent but I want the result to be in a variable.

    I tried like this :

    my $content = sprintf $para->text()."\n";

    It doesn't seem to work.
      Yes it works that way.

      If there is any other way then tell me.

      Once again... read the docs. perldoc -f sprintf. If the text of the element includes a % you won't get what you want.

      You don't need sprintf at all in this case. my $content = $para->text()."\n"; will do just fine.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://729154]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2015-07-04 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls