How to Prevent XML with blank lines when I download it?

I download files from a HTTPS Secure Webpage.

So I use a HTTPSecureSocket to do it. I download files normally, I set it with SetRequest Header passing the required Cookie in order to download files, My code is this:

[code] Dim SAVEFILE as FolderItem = SpecialFolder.Documents.Child(“CFDieBrain”).Child(TipoFacturaSol).Child(RFCInvestigado).Child(Year).Child(Mes).Child(EmisorFiltrado).Child(FileName.Uppercase+".xml")

//ESPECIFICAMOS LOS DATOS DEL SOCKET SEGURO O COMO LO LLAMAN EN VB.NET "WEBCLIENT"*******//
downloadSocket.Secure = True 'HABILITAMOS LA OPCION SEGURA, DE LO CONTRARIO SERIA UN SOCKET SIMPLE
downloadSocket.Port = 443 'ESPECIFICAMOS EL PUERTO DE CONEXIN, EN ESTE CASO SER EL 443
downloadSocket.ConnectionType = 3 'ESPECIFICAMOS EL TIPO DE CONEXIN
downloadSocket.SetRequestHeader(“Accept”, "
/
") 'ACEPTAMOS LOS SIGUIENTES CARACTERES
downloadSocket.SetRequestHeader(“Accept-Encoding:”,“gzip,deflate,sdch”) ’ ACEPTAMOS LOS SIGUIENTES TIPOS DE CODIFICACIN
downloadSocket.SetRequestHeader(“User-Agent:”,“Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36”) 'ESTABLECEMOS LOS DIFERENTES TIPOS DE NAVEGADOR A SOPORTAR
downloadSocket.SetRequestHeader(“Connection”, “keep-alive”) ’ ESTABLECEMOS QUE QUEREMOS MANTENER VIVA LA CONEXIN
downloadSocket.SetRequestHeader(“Accept-Language”, “en-US,en;q=0.8”) 'ESTABLECEMOS EL TIPO DE LENGUAJE
downloadSocket.SetRequestHeader(“Cookie”, CookieName) 'Y FINALMENTE LA PARTE MAS “BELLA”, HACEMOS LA PETICIN AL HEADER CON LA COOKIE GUARDADA “COOKIENAME” PARA IDENTIFICARNOS EN EL SERVIDOR

//SI EL ENLACE HA SIDO DESCARGADO EXITOSAMENTE ATRAVES DEL SOCKET, ENTONCES MOSTRAR UN MENSAJE DE EXITO.
if downloadSocket.Get(enlace, SAVEFILE, 30) = True then
Msgbox “Successfully Downloaded”
End If
[/code]

Where downloadSocket = HttpSecureSocket
And Enlace = URL to Download
SAVEFILE = Folder to download the file

And in SetRequestHeader “Cookie” is the name of the cookie.

But the real problem starts with when I download XML files as it normal, sometimes I download the normal XML and sometimes I download details but with a little detail.

At First of the code XML it writes THREE EMPTY LINES before the normal code <xml bla bla bla bla
I think that I forgetting something in SetRequest Header.

And Also I dunno how to set in Accept-Language to Spanish-Spain or Spanish-Mexico instead of en-US,en;q=0.8

The idea here is that I wanna download all the XML but without these three empty lines.
Am I wrong?

Thanks

Maybe this?

SetRequestHeader("Content-Type","text/xml")

The Accept-Language header can include more than one language. Each additional language is separated by a comma. For example:

es (Spanish) de (German) en (English) it (Italian) en-US (English/United States) en-GR (English/United Kingdom) es-ES (Spanish/Spain) es-MX (Spanish/Mexico) pt-BR (Portuguese/Brazil)

accept-language: es-mx,es,en

And here a link with language accept from browsers languages

I do the changes, And I’m continuing download XMLS with two lines before the code Starts, like This:

[quote]

<?xml version="1.0" encoding="utf-8"?><cfdi:Comprobante [/quote]

Not Only write spaces at principle of code, also writes this: .

My code at this time is:

downloadSocket.Secure = True 'HABILITAMOS LA OPCION SEGURA, DE LO CONTRARIO SERIA UN SOCKET SIMPLE downloadSocket.Port = 443 'ESPECIFICAMOS EL PUERTO DE CONEXIN, EN ESTE CASO SER EL 443 downloadSocket.ConnectionType = 3 'ESPECIFICAMOS EL TIPO DE CONEXIN downloadSocket.SetRequestHeader("Accept", "*/*") 'ACEPTAMOS LOS SIGUIENTES CARACTERES downloadSocket.SetRequestHeader("Accept-Encoding:","gzip,deflate,sdch") ' ACEPTAMOS LOS SIGUIENTES TIPOS DE CODIFICACIN downloadSocket.SetRequestHeader("User-Agent:","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36") 'ESTABLECEMOS LOS DIFERENTES TIPOS DE NAVEGADOR A SOPORTAR downloadSocket.SetRequestHeader("Connection", "keep-alive") ' ESTABLECEMOS QUE QUEREMOS MANTENER VIVA LA CONEXIN downloadSocket.SetRequestHeader("Accept-Language", "es-mx,es,en;q=0.8") 'ESTABLECEMOS EL TIPO DE LENGUAJE downloadSocket.SetRequestHeader("Content-Type","text/xml") downloadSocket.SetRequestHeader("Cookie", CookieName) 'Y FINALMENTE LA PARTE MAS "BELLA", HACEMOS LA PETICIN AL HEADER CON LA COOKIE GUARDADA "COOKIENAME" PARA IDENTIFICARNOS EN EL SERVIDOR

I think I solved changing back the Language to en-US

if you get strange chars include

Content-Type: application/xml; CharSet=UTF-8

[quote=261158:@Loannis Kolliageorgas]if you get strange chars include

Content-Type: application/xml; CharSet=UTF-8

Thanks I tried that you said, In fact I don’t have blank lines anymore.

Now Using “es” I have accented characters.

But sometimes fails, like this case: unidad=“Pza.” descripcion=“Caf? Nestl? Taster” valorUnitario=“82”

Instead of say: unidad=“Pza.” descripcion=“Café Nestlé Taster” valorUnitario=“82”

Is there a way to solve that?

That’s the final line of code that I’m using:
downloadSocket.SetRequestHeader(“Accept-Language”, “es;q=0.8”)

But I realize that Downloading the requested XML directly from webpage, not from my downloader.

It says: Caf? Nestl? Taster

How can I avoid this strange signs?
Because this Strange signs are responsible that my program crash when Im importing the XML file.

Thanks

I solved at the Insertion point of “Description” of the XML I do a ReplaceALL like this:

Description.ReplaceAll("?","e")

This is exactly the right post to read http://blog.xojo.com/2013/08/20/why_are_there_diamonds_in_my_user_interface/

Thanks Norman, I’ll gonna read it