我采用http协议post方式上报XML文件到一个url,到了服务器端解析的时候,发现发送的
<?xml version="1.0" encoding="GBK"?>变成了<?xml version=%221%2EO%22+encoding%3D%22GBK%22%3F%3E&
请问是怎么回事啊?

解决方案 »

  1.   

    编码的问题,你看看服务器是不是也是GBK编码。
    GBK编码下输入<?xml version="1.0" encoding="GBK"?>在
    在UFT-8编码下就是
    <?xml version=%221%2EO%22+encoding%3D%22GBK%22%3F%3E&
      

  2.   

    代码如下
               XMLDoc := TXMLDocument.create(Nil);
              XMLDoc.Active := true;
              XMLDoc.Version := '1.0';
              XMLDoc.Encoding := 'GBK';
              url := 'http://192.168.0.8:8080/proxy/plproxy?swglm=320200004031696';
              IdHTTP := TIdHTTP.create(Nil);
              IdHTTP.Request.AcceptEncoding := 'gbk';
              IdHTTp.Request.AcceptCharSet := 'GBK';
              IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
              IdHTTP.Request.ContentLength := Length(Memo1.Text);
              strsends := tstringlist.create;
              strsends.AddStrings(XMLDoc.xml);
              strResult := IdHTTP.Post(url, strsends);
      

  3.   

    IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
    改成
    IdHTTP.Request.ContentType := 'text/xml; charset=gb2312'
    试试
      

  4.   

    还是不行。
    服务端报错:“error on line 1:the value flllowing "version" in the xml declaration must be a quoted string. ”