[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

perl, how to print xml element

Posted on 2011-05-12
2
Medium Priority
?
564 Views
Last Modified: 2012-05-11
How to print $response?
perl code:
    my $response = XML::LibXML::Element->new("response");

    my $message_response = XML::LibXML::Element->new("element1");
    $message_response->appendChild(XML::LibXML::Element->new("tag1"));
    $message_response->appendChild(XML::LibXML::Element->new("tag2"));
    $response->appendChild($message_response);


0
Comment
Question by:rgbcof
2 Comments
 
LVL 10

Accepted Solution

by:
SANTABABY earned 2000 total points
ID: 35750329
Please try the following:
my $xmlstr
$xmlstr = $response->toString($format,$docencoding);

(See below for daetisl on the arguments to the function).

This function is defined in XML::LibXML::Node .

Useful Ref: http://perl.enstimac.fr/perl5.6.1/site_perl/5.6.1/sun4-solaris/XML/LibXML/Node.html
0
 

Author Closing Comment

by:rgbcof
ID: 35750934
It was an element, so I had to use ->textContent()
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question