I need to generated an xml to load on an internet site, from my SQL2005 DB. All work fine, but when the file is loaded on the webservice that need it, I've this error:
'.', hexadecimal value 0x00, is an invalid character. Line 1, position 41.
The xml code work fine, but I think the problem is in the file. The Xml is generated with this query
set @cmd = 'bcp "SELECT XML FROM ' + @DBNAME + '.dbo.FATTELETTR WHERE PROGRESSIVO LIKE ' + @PROGRESSIVO + ' " queryout ' + @Filename + ' -U user -P pass -w -r -t -x';
--print @cmd
EXEC XP_CMDSHELL @cmd, no_output;
This is a file example:
<?xml version="1.0" encoding="UTF-8" ?> <p:FatturaElettronica versione="FPR12" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd">
<FatturaElettronicaHeader>
................ content............
</FatturaElettronicaHeader>
<FatturaElettronicaBody>
................ content............
</FatturaElettronicaBody></p:FatturaElettronica>
If I take directly the file generated, I've the error, INSTEAD if I take the xml content, create a new xml file, and paste the contents copied to the one manually created, all work fine and I've no error.
Also if I try to open on internet explorer the xml files, the sql generated one is empty, I see a blank page, instead the one manually created is loaded fine.
So the file has the problem. But which is?