Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I just have to say it is very difficult to read your code. Maybe you can indent it properly. People would be much more inclined to try and help you. Also, are we supposed to know what is in 'example.xml'. Posting complete code listings is also not very useful. Try to simplify your question. Reading your code I am absolutely clueless in what you are actually try to do.

Nevertheless to help you on your way a little bit, try to focus on the actual problem. What is the problem? Is the problem in the part that examines the two csv files or is it in the server request. As a matter of fact that is where I would look first.

Create a small sample code for testing and once you have that part working, then start working on the rest of your code.

For example

I suggest you use strict and warnings, it will help you identify problems in your code much sooner.

use strict ; use warnings ;
my $xml = XML::Twig->new()->parsefile('example.xml') ; $xml-> ... ; $xml -> get_xpath('//ipaddress',0) -> set_text("<IP HERE>") ;

Write a test to check if the previous instruction worked. I don't know, are these of HTML::Element XML::Element? If so then print $xml->as_text() print $xml->as_XML could work. Once you know this worked, then move on:

my $uri="https://hostname:9060/ers/config/networkdevice/<ID HERE>"; my $req = HTTP::Request->new( ... $req->content($xml->sprint) ; # Strange, why is there another $xml->sp +rint here? $req->...

Now try to find more ways to introspect $req and see if it contains everything you want. Try to do a request and see if it works:

my $res = $ua->request( $req ) ; # Check the outcome of the response if ($res->is_success) { print $res->status_line, "\n"; } else { print $res->status_line, "\n"; }

edit: forgot to add the Twig parsefile instruction.


In reply to Re: HTTP PUT Request with separate values in csv by Veltro
in thread HTTP PUT Request with separate values in csv by StayCalm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-23 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found