易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi与XML文档

同步程序案例
procedure TGetOrderThread.PostDB(webnr:WideString);
var
  Err: String;
  SetWebnr:WideString;
  xmlDoc: IXMLDocument;
  root: IXMLNode;
  rowc: IXMLNode;//记录数
  rows: IXMLNodeList;//主记录列表
  row: IXMLNode;
  drows: IXMLNodeList;//明细列表
  drow: IXMLNode;
  i,j,slhj,jlhj:integer;
  djhj:real;
begin
  //同步数据
  xmlDoc := TXMLDocument.Create(nil);
  try
    xmlDoc.XML.Text:=Webnr;
    xmlDoc.Active:=true;
    root:=xmlDoc.DocumentElement;
    rowc:=root.ChildNodes.FindNode('RowC');
    if (rowc.NodeValue>0) and DBconn then
    begin
      rows:=root.ChildNodes.FindNode('RowS').ChildNodes;
      //showmessage('记录数:'+rowc.NodeValue);
      for i:=0 to rows.Count-1 do
      begin
        ADOConn.BeginTrans;
        try
          row:=rows.Nodes[i];
          drows:=row.ChildNodes.FindNode('Drows').ChildNodes;
          //showmessage(row.ChildValues['billno']+
          //  ' 明细记录数:'+inttostr(drows.Count));//显示订单号
          if SHelper.Active then SHelper.Close;
          SHelper.SQL.Text:=Format(selectStr,[row.ChildValues['billno']]);
          SHelper.Open;
          jlhj:=0;
          slhj:=0;
          djhj:=0;
 &nb


相关文档:

Delphi的快捷键


 
//**************需要强调的两个快捷键**********************
51.CTRL+SHIFT+U     代码整块左移2个空格位置
52.CTRL+SHIFT+I     代码整块右移2个空格位置
60.Ctrl+Alt+c       注释块
61.Ctrl+Alt+u    & ......

解析xml文件的几种常见的方法

xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<mobile-list>
<mobile type="Nokia2652">
<wap2>false</wap2>
<width>115</width>
</mobile>
<mobile type="Nokia2650">
......

使用SimpleXML函数来加载和解析XML文档

 大量SmipleXML函数可用来加载和解析大量XML文档。
1.simpleXML_load_file()函数来加载指定的XML文件到对象。如果加载文件时遇到问题,则返回FLASE。例:
book.xml文件:
<?xml version="1.0" standalone="yes"?>
<library>
<book>
<title>Pride and Prejudice</title>
< ......

用jdom来解析xml文件

xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<mobile-list>
<mobile type="Nokia2652">
<wap2>false</wap2>
<width>115</width>
</mobile>
<mobile type="Nokia2650">
......

php之XML转数组函数

<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号