in reply to HTTP Post of XML data

Well after looking around and talking to the java guy, I have found that the closing tag I am trying to send is incorrect. The XML::Writer wanted me to close the tag exactly the same way I opened it, so I put the whole
$writer->endTag("manager xmlns:xsi=http://www.w3.org/2001/XMLSchema-in +stance");
I need to just close it with:
$writer->startTag("manager xmlns:xsi=http://www.w3.org/2001/XMLSchema- +instance"); ..... .... .... $writer->endTag("manager"); $writer->end;
But it is failing. In the documentation it states:
NAMESPACES A true (1) or false (0, undef) value; if this parameter is present + and its value is true, then the module will accept two-member array +reference in the place of element and attribute names, as in the foll +owing example: my $rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; my $writer = new XML::Writer(NAMESPACES => 1); $writer->startTag([$rdfns, "Description"]); The first member of the array is a namespace URI, and the second p +art is the local part of a qualified name. The module will automatica +lly generate appropriate namespace declarations and will replace the +URI part with a prefix.
I was trying something like this:
my $rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; my $writer = new XML::Writer(OUTPUT => \$output, NAMESPACES => 1); $writer->startTag([$rdfns, "Description"]); $writer->startTag("greeting", "class" => "simple"); $writer->characters("Hello, world!"); $writer->endTag("greeting"); $writer->endTag("Description"); $writer->end(); print $output;
But I get: Attempt to end element "ARRAY(0x814ec28)" with "Description" tag, when I don't have NAMESPACES => 1, and when I do add it, I get something similar: Attempt to end element "__NS1:Description" with "Description" tag Any leads Monks?

Replies are listed 'Best First'.
Re^2: HTTP Post of XML data
by hallikpapa (Scribe) on Nov 14, 2007 at 20:50 UTC
    After much fiddling, I am just down to how to do post an array @data, to the URL? It only posts the first line in the array. I have an array @data that holds a bunch of XML data. I am trying to send it all to port 8180 on the localhost to another application, but it is only sending the first line. What is the best way to send the entire array as is? A foreach loop would open a new connection each time instead of sending it all as one stream, correct? Cause when I do it like this, it only posts the opening tag.
    my $browser = LWP::UserAgent->new; ... ... ... open(FILE,"output.xml"); my @data = <FILE>; my $response = $browser->post( $url, Content => @data );