in reply to saving sql data in xml formatted file

Have you looked at or attempted to use any of the XML modules? I think a good starting point would be there.
Also, for the XML output have you decided what the output is going to look like (i.e. XML schema/dtd)?..as XML is not freeform like text.
Lastly, the SQL query construct is absolutely horrible, and you should seriously consider refactoring how that's done. Which will greatly aid in making the code less likely to fail in trivial variations in the data, and more flexible and maintainable. Also looks like the input data is of questionable quality. For example a server http response code would be much better to use instead of the human readable response, which differs between web server setups.
Anyway, hope you don't take this personally, as my opinion is just based on the code presented. Which could do with improvement to make it reliable.
the hardest line to type correctly is: stty erase ^H
  • Comment on Re: saving sql data in xml formatted file