IxmlDocument 的2个保存方法区别

andyLe 2003-02-28 10:14:26
IXMLDocument.SaveToXML 和 IXMLDocument.SaveToFile
如果该xmlDoc的内容比较小,那么他们得到结果是一样,但是内容大到一定程度(也不会很多),savetoxml就出现了问题了,后面很多东西被截掉了,而saveToFile成功(不管多大)。
大家知道为什么吗?需要答案,高手高高手请告诉我呀‘
...全文
35 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
andyLe 2003-03-03
  • 打赏
  • 举报
回复
不好意思,是我自己没有注意。本来是没有区别,得到的结果都是一样。
只是在socket通讯的时候,没有能够把xml string一次性发过来,导致截掉。。
halfdream 2003-02-28
  • 打赏
  • 举报
回复
字符串多长的时候被截掉的?
unit XMLexample; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, xmldom, XMLIntf, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, StdCtrls, Buttons, cxContainer, cxListBox, msxmldom, XMLDoc; type TForm1 = class(TForm) XMLDocument1: TXMLDocument; lstSource: TcxListBox; lstTarget: TcxListBox; SpeedButton2: TSpeedButton; SpeedButton1: TSpeedButton; SpeedButton3: TSpeedButton; SpeedButton4: TSpeedButton; SpeedButton6: TSpeedButton; SpeedButton5: TSpeedButton; SpeedButton7: TSpeedButton; SpeedButton8: TSpeedButton; Button1: TButton; cxListBox1: TcxListBox; cxListBox2: TcxListBox; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure SpeedButton2Click(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton3Click(Sender: TObject); procedure SpeedButton6Click(Sender: TObject); procedure SpeedButton5Click(Sender: TObject); procedure SpeedButton7Click(Sender: TObject); private { Private declarations } public procedure MoveUp(A: TcxListBox); //上移 procedure MoveDown(A: TcxListBox); //下移 procedure DeleteItem(A: TcxListBox); //删除 procedure ReLoadItems(A: TcxListBox; const Flag: Integer = 0); //重置 procedure CreateXML(APath:string); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin CreateXML('C:\Documents and Settings\Administrator\桌面\XML'); end; procedure TForm1.Button2Click(Sender: TObject); var Node: IXMLNode; Root: IXMLNode; //根节点 ParentNode: IXMLNode; //首节点 StrDir: string; xmlDocument: IXMLDocument; I: Integer; begin xmlDocument := TXMLDocument.Create(nil); StrDir := 'C:\Documents and Settings\Administrator\桌面\XMLConfig.xml'; xmlDocument.XML.LoadFromFile(StrDir); xmlDocument.Active := true; Root := xmlDocument.DocumentElement; //源字段 ParentNode:=Root.ChildNodes.FindNode('FieldsFromSource'); for I := 1 to ParentNode.ChildNodes.Count - 1 do begin Node:=ParentNode.ChildNodes[i]; cxListBox1.Items.Add(Node.ChildValues['FieldName']); end; //目标字段 ParentNode:=Root.ChildNodes.FindNode('FieldsFromTarget'); for I := 1 to ParentNode.ChildNodes.Count - 1 do begin Node:=ParentNode.ChildNodes[i]; cxListBox2.Items.Add(Node.ChildValues['FieldName']); end; end; procedure TForm1.CreateXML(APath: string); var xmlDocument: IXMLDocument; sDir: string; i:Integer; begin xmlDocument := TXMLDocument.Create(nil); with xmlDocument.XML do begin //开始写XML Add(''); Add(''); //源字段信息写入XML if lstSource.Count>0 then begin Add(''); Add('' + IntToStr(lstSource.Count) + ''); for I := 0 to lstSource.Count - 1 do begin Add(''); Add('' + IntToStr(i) + ''); Add(''+ lstSource.Items[i]+''); Add(''+ ''+''); Add(''+ ''+''); Add(''+ ''+''); Add(''+ ''+''); Add(''); end; Add(''); end else begin Add(''); Add('0'); Add(''); end; //目标字段写入XML if lstTarget.Count>0 then begin Add(''); Add('' + IntToStr(lstTarget.Count) + ''); for I := 0 to lstTarget.Count - 1 do begin Add(''); Add('' + IntToStr(i) + ''); Add(''+ lstTarget.Items[i]+''); Add(''+ ''+''); Add(''+ ''+''); Add(''+ ''+''); Add(''+ ''+''); Add(''); end; Add(''); end else begin Add(''); Add('0'); Add(''); end; Add(''); //XML注释 Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); Add(''); //XML结束 end; xmlDocument.Active := True; sDir := APath; if not DirectoryExists(sDir) then begin if not CreateDir(sDir) then begin ShowMessage('创建文件夹失败'); Exit; end; end; xmlDocument.SaveToFile(sDir + 'Config.xml'); end; procedure TForm1.DeleteItem(A: TcxListBox); var _Index: Integer; begin with A do begin if (Items.Count > 0) and (ItemIndex <> -1) then begin _Index := ItemIndex; Items.Delete(_Index); end; end; end; procedure TForm1.MoveDown(A: TcxListBox); var CurrIndex, LastIndex: Integer; begin with A do begin CurrIndex := ItemIndex; LastIndex := Items.Count; if ItemIndex <> -1 then begin if CurrIndex + 1 < LastIndex then begin Items.Move(ItemIndex, (CurrIndex + 1)); ItemIndex := CurrIndex + 1; end; end; end; end; procedure TForm1.MoveUp(A: TcxListBox); var CurrIndex: Integer; begin with A do begin if ItemIndex > 0 then begin CurrIndex := ItemIndex; Items.Move(ItemIndex, (CurrIndex - 1)); ItemIndex := CurrIndex - 1; end; end; end; procedure TForm1.ReLoadItems(A: TcxListBox; const Flag: Integer); begin end; procedure TForm1.SpeedButton1Click(Sender: TObject); begin MoveDown(lstSource); end; procedure TForm1.SpeedButton2Click(Sender: TObject); begin MoveUp(lstSource); end; procedure TForm1.SpeedButton3Click(Sender: TObject); begin DeleteItem(lstSource); end; procedure TForm1.SpeedButton5Click(Sender: TObject); begin MoveDown(lstTarget); end; procedure TForm1.SpeedButton6Click(Sender: TObject); begin MoveUp(lstTarget); end; procedure TForm1.SpeedButton7Click(Sender: TObject); begin DeleteItem(lstTarget); end; end.
源码8 IDOMDocument vs. IXMLDocument.... . 8 TXMLDocument Programming .... 9 XML TreeView .. 12 TXMLDocument as Windows Service........................................... 14 XML Data Binding .............................................................................. 16 Generated Code ...................................................................... 20 Delphi XML Mapper............................................................................ 23 The XML Mapping Tool.............................................................. 23 Selecting Nodes ...................................................................... 24 Create and Test Transformation................................................. 26 XMLTransform......................................................................... 28 Visual Transformation .............................................................. 30 TXMLTransformClient ............................................................... 31 XSLT ............................................................................................... 32 XSL Transformations................................................................ 32 MSXSL ................................................................................... 32 Some examples of XSLT.................................................... 32 Default XSLT Templates ........................................................... 34 Our own XSLT Processor........................................................... 35 XML and XSL .......................................................................... 35 XMLData property ............................................................ 35 FileName property............................................................ 35 XML property................................................................... 36 XSLT Processor ....................................................................... 37 Alternative Approach ........................................................ 37 Summary......................................................................................... 38 2. Web Services: SOAP & WSDL 39 Web Services.................................................................................... 39 SOAP..................................................................................... 39 WSDL .................................................................................... 39 XSD Data Types ...................................................................... 41 SOAP and XML ........................................................................ 41 Building Delphi for Win32 Web Services................................................ 42 Debug and ISAPI..................................................................... 43 Second target (Indy) ........................................................ 44 SOAP Web Module............................................................ 45 SOAP Server Interface ............................................................. 47 SOAP Server Implementation .................................................... 51 Indy VCL Project ............................................................................... 53 Consuming Web Services.................................................................... 55 SOAP Client ............................................................................ 56 Using GetIEcho ....................................................................... 60 Delphi XML, SOAP & Web Services Bob Swart Training & Consultancy - iii - www.drbob42.com Using THTTPRIO...................................................................... 64 WSDL vs. SOAP....................................................................... 65 AdminEnabled......................................................................... 66 GetIEcho Implementation ......................................................... 69 Conversion Web Services.................................................................... 70 TemperatureIntf...................................................................... 72 TemperatureImpl .................................................................... 72 Debugging Web Services .................................................................... 73 Web Service Client................................................................... 73 Server Breakpoints .................................................................. 74 Deployment on Windows Server 2003 and IIS ....................................... 75 Enabling ISAPI / CGI................................................................ 75 Virtual Directory ...................................................................... 76 SSL Certificates................................................................................. 79 SSL and IIS6 on Windows Server 2003....................................... 79 Installing SSL Certificates ......................................................... 82 Deployment on Windows Server 2008 and IIS7 ........................... 83 Tracing Web Services......................................................................... 88 SOAP and Exceptions ......................................................................... 89 Echo Interface unit .................................................................. 89 Echo implementation unit ......................................................... 89 Echo import unit...................................................................... 90 Extending SOAP Exceptions....................................................... 90 SOAP and Databases ......................................................................... 92 Database Client....................................................................... 94 Extra Data Module ................................................................... 96 Alternative to data module: web module..................................... 98 SOAP Attachments ............................................................................ 98 Receiving SOAP Attachments .................................................... 101 Summary......................................................................................... 103 Exercises.......................................................................................... 103 Exercise #1 ............................................................................ 103 Exercise #2 ............................................................................ 103 Exercise #3 ............................................................................ 103 Exercise #4 ............................................................................ 103 Exercise #5 ............................................................................ 103 Exercise #6 ............................................................................ 103 Exercise #7 ............................................................................ 103 Exercise #8 ............................................................................ 103 3. SOAP and Security 105 SSL Certificates................................................................................. 105 Web Service Example......................................................................... 105 SourceCodeIntf................................................................ 105 SourceCodeImpl .............................................................. 106 Importing Win32 Secure Web Service ................................. 107 Summary......................................................................................... 108 Exercises.......................................................................................... 108 Exercise #1 ............................................................................ 108 Exercise #2 ............................................................................ 108 Exercise #3 ............................................................................ 108 4. Case Study: Automatic Updates 109

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧