Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hai to all


I am new to XML::Twig module. Once I parse a file using XML::Twig, the whole file contents stored in a twig object. The file contents can be saved to a file, but how to assign that file content to a variable


Thanks in advance


Rudhra

  • Comment on How to assign xml content to a variable using XML::Twig module

Replies are listed 'Best First'.
Re: How to assign xml content to a variable using XML::Twig module
by PodMaster (Abbot) on Aug 23, 2004 at 10:35 UTC
    You simply eat the twig :D

    But seriously, there is a method documented right next to print which will do what you wish. Can you guess what it is called? It starts with an s and ends with a print :)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: How to assign xml content to a variable using XML::Twig module
by murugu (Curate) on Aug 23, 2004 at 10:56 UTC

    update: I have posted the previous reply. Sorry for the duplicate post.

    First, What is the need for storing the same xml file content after parsing, in to another variable?. Is it for Post processing the Xml part as ordinary text?

    I have the below answer upto what i have understood from ur question above.

    use XML::Twig; my $twig=new XML::Twig; $twig->parsefile($ARGV[0]); $ARGV[0] is input xml file. $a=$twig->sprint; ##### storing the xml content into a variable. print $a;

    Please forgive me for my english.

    ------Murugesan---------