我的一段代码(摘录,其他的执行正常):    XMLDocument1.XML.Add(cXMLStr);
    oReg:=CoXMLHTTPRequest.Create();
    oReg.open('POST',SysInf.cURL,False,varEmpty,varEmpty);
    oReg.send(XMLDocument1.XML.Text);
    ShowMessage(oReg.responseText);  //这里显示正常
    XMLDocument1.XML.Clear ;
    XMLDocument1.Add(oReg.responseText);    XMLDocument1.Active := True;
   一执行到XMLDocument1.Active := True这句时出现错误,提示“An Invalid chraracter was found in text content”,不知是何原因,请大虾帮忙。
    XML串内容正常,可以在IE中显示。
 

解决方案 »

  1.   

    <?xml version="1.0" encoding="UTF-8" ?> 
    - <ufinterface billtype="" filename="" isexchange="Y" proc="" receiver="" replace="Y" roottag="sendresult" sender="">
    - <sendresult>
      <billpk /> 
      <bdocid /> 
      <filename /> 
      <resultcode>-6</resultcode> 
      <resultdescription>从输入流转换document出错:请检验文档格式.</resultdescription> 
      <content /> 
      </sendresult>
      </ufinterface>这是oReg.responseText返回的串。
      

  2.   

    XMLDocument1.XML.Clear ; 这句为什么要清掉呢 XML不能把它的超文本标识清掉
      

  3.   

    不清就重复了,后发现一个现象,如果把encoding="UTF-8" 改成encoding="gb2312"就可以了,不知道为什么?哪位大虾进来搭救下?
      

  4.   


    http://www.delphibbs.com/keylife/iblog_show.asp?xid=17299       delphi操作xml学习笔记 之一 入门必读
    http://www.delphibbs.com/keylife/iblog_show.asp?xid=17439       delphi操作xml学习笔记 之二 简单读写
    http://www.delphibbs.com/keylife/iblog_show.asp?xid=17482       delphi操作xml学习笔记 之三 进阶必读
    http://www.delphibbs.com/keylife/iblog_show.asp?xid=17530       delphi操作xml学习笔记 之四 简单增删查
      

  5.   

    楼上这位zuoansuifeng大虾,能否具体指导一下,我相信是某个设置的问题,因为把串存到文件里在IE里打开格式是没问题的,换成gb2312就没问题。
    谢谢了。
      

  6.   

    是的 可以用窜的形式来存 刚开始我写XML的时候也是无从下手 就以字符窜的形式写进XML里面去
    写进XML文件的时候一般要注意 比如 起头 <?xml version="1.0" encoding="GB2312"?>  
    encoding 对应的标识玛一般情况下我们都是用GB2312来对应XML 
    其次窜的写入应该在这种格式之间 <UpdateFree>  </UpdateFree>
    字符窜一般写成如下格式 <file name="Phook.dll" size="16711933" isreg="2" version="5" dest="\" time="2006-8-4 11:08:06"/>