我这样写的:var
  xml: String;
  doc: IXMLDOMDocument;
...
...xml:= TDataTools.getDataSetXml(dataSet);
doc:=CreateOleObject('Microsoft.XMLDOM') as IXMLDomDocument;
doc.loadXML(xml);
// 这里doc.documentElement有时为nil
...它loadXML之后有时为nil,有时不为nil,这是怎么回事??

解决方案 »

  1.   

    为nil时的xml为:
    <?xml version="1.0" standalone="yes"?>  
    <DATAPACKET Version="2.0">
    <METADATA><FIELDS>
    <FIELD attrname="ACCOUNT_ID" fieldtype="string" WIDTH="30"/><FIELD attrname="ACC_CODE_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="ACC_CODE_IID" fieldtype="string" WIDTH="60"/><FIELD attrname="ACC_CODE_NAME" fieldtype="string" WIDTH="230"/><FIELD attrname="ACC_TOPCODE_IID" fieldtype="string" WIDTH="1"/><FIELD attrname="AMOUNT" fieldtype="r8"/><FIELD attrname="AUDITOR" fieldtype="string" WIDTH="30"/><FIELD attrname="AUDITOR_NAME" fieldtype="string" WIDTH="200"/><FIELD attrname="BILL_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="BILL_SOURCE" fieldtype="string" WIDTH="30"/><FIELD attrname="BK_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="BK_DATE" fieldtype="date"/><FIELD attrname="BK_TYPE" fieldtype="i4"/><FIELD attrname="BK_TYPENAME" fieldtype="string" WIDTH="1"/><FIELD attrname="CITY" fieldtype="string" WIDTH="1"/><FIELD attrname="CO_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="DESCPT" fieldtype="string" WIDTH="200"/><FIELD attrname="FISCAL" fieldtype="i4"/><FIELD attrname="IID" fieldtype="string" WIDTH="60"/><FIELD attrname="INPUTOR" fieldtype="string" WIDTH="30"/><FIELD attrname="INPUTOR_NAME" fieldtype="string" WIDTH="200"/><FIELD attrname="IN_ACCOUNT_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="IN_ACCOUNT_IID" fieldtype="string" WIDTH="60"/><FIELD attrname="IN_BANK_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="IN_BANK_NAME" fieldtype="string" WIDTH="200"/><FIELD attrname="IN_CITY" fieldtype="string" WIDTH="1"/><FIELD attrname="IN_CO_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="IN_CO_IID" fieldtype="string" WIDTH="60"/><FIELD attrname="IN_CO_NAME" fieldtype="string" WIDTH="230"/><FIELD attrname="IN_PROVINCE" fieldtype="string" WIDTH="1"/><FIELD attrname="IN_UP_BANK_CODE" fieldtype="string" WIDTH="1"/><FIELD attrname="IN_UP_BANK_NAME" fieldtype="string" WIDTH="1"/><FIELD attrname="ISCREATED" fieldtype="string" WIDTH="1"/><FIELD attrname="IS_ACCESS" fieldtype="string" WIDTH="1"/><FIELD attrname="IS_MODIFY" fieldtype="string" WIDTH="1"/><FIELD attrname="LB01" fieldtype="string" WIDTH="60"/><FIELD attrname="LB02" fieldtype="string" WIDTH="60"/><FIELD attrname="LB03" fieldtype="string" WIDTH="60"/><FIELD attrname="LB04" fieldtype="string" WIDTH="60"/><FIELD attrname="LB05" fieldtype="string" WIDTH="60"/><FIELD attrname="LB06" fieldtype="string" WIDTH="60"/><FIELD attrname="LB07" fieldtype="string" WIDTH="60"/><FIELD attrname="LB08" fieldtype="string" WIDTH="60"/><FIELD attrname="LB09" fieldtype="string" WIDTH="60"/><FIELD attrname="LB10" fieldtype="string" WIDTH="60"/><FIELD attrname="LB11" fieldtype="string" WIDTH="60"/><FIELD attrname="LB12" fieldtype="string" WIDTH="60"/><FIELD attrname="LB13" fieldtype="string" WIDTH="60"/><FIELD attrname="LB14" fieldtype="string" WIDTH="60"/><FIELD attrname="LB15" fieldtype="string" WIDTH="60"/><FIELD attrname="LB16" fieldtype="string" WIDTH="60"/><FIELD attrname="LB17" fieldtype="string" WIDTH="60"/><FIELD attrname="LB18" fieldtype="string" WIDTH="60"/><FIELD attrname="LB19" fieldtype="string" WIDTH="60"/><FIELD attrname="LB20" fieldtype="string" WIDTH="60"/><FIELD attrname="OUT_ACCOUNT_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="OUT_ACCOUNT_IID" fieldtype="string" WIDTH="60"/><FIELD attrname="OUT_BANK_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="OUT_BANK_NAME" fieldtype="string" WIDTH="200"/><FIELD attrname="OUT_CITY" fieldtype="string" WIDTH="1"/><FIELD attrname="OUT_CO_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="OUT_CO_IID" fieldtype="string" WIDTH="60"/><FIELD attrname="OUT_CO_NAME" fieldtype="string" WIDTH="230"/><FIELD attrname="OUT_PROVINCE" fieldtype="string" WIDTH="1"/><FIELD attrname="OUT_UP_BANK_CODE" fieldtype="string" WIDTH="1"/><FIELD attrname="OUT_UP_BANK_NAME" fieldtype="string" WIDTH="1"/><FIELD attrname="PROVINCE" fieldtype="string" WIDTH="1"/><FIELD attrname="VOUCHER_IID" fieldtype="string" WIDTH="30"/><FIELD attrname="VOU_DATE" fieldtype="string" WIDTH="1"/><FIELD attrname="VOU_IID" fieldtype="string" WIDTH="1"/><FIELD attrname="VOU_NO" fieldtype="string" WIDTH="1"/><FIELD attrname="YSW_IID" fieldtype="string" WIDTH="60"/><FIELD attrname="ZB_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="ZGBM" fieldtype="string" WIDTH="1"/><FIELD attrname="ZGC" fieldtype="string" WIDTH="1"/>
    </FIELDS><PARAMS CHANGE_LOG="1 0 4 2 1 8 3 2 8"/>
    </METADATA><ROWDATA><ROW RowState="5" ACCOUNT_ID="YSW" ACC_CODE_CODE="11011" ACC_CODE_IID="104824663732783567949530" ACC_CODE_NAME="11011 财政专户存款" BILL_SOURCE="00" BK_CODE="00015" BK_DATE="20080526" BK_TYPE="0" BK_TYPENAME="? CO_CODE="000" FISCAL="2007" IID="10111834733188580568430" INPUTOR="sa" INPUTOR_NAME="系统管理员" IN_ACCOUNT_CODE="01090517900120105114338" IN_ACCOUNT_IID="104821544733027385249210" IN_BANK_NAME="北京银行海淀路支行" IN_CO_IID="104821544733027383718750" IN_CO_NAME="北京正元伟业科技发展有限公司" LB01="" LB03="" LB04="" LB05="" LB06="" LB07="" LB08="" LB09="" LB10="" LB11="" LB12="" LB13="" LB14="" LB15="" LB16="" LB17="" LB18="" LB19="" LB20="" OUT_ACCOUNT_CODE="0200001409014420374" OUT_ACCOUNT_IID="1048246204732884367920000" OUT_BANK_NAME="工行百万庄支行" OUT_CO_IID="1048246112732779624417500" OUT_CO_NAME="北京市财政局" YSW_IID=""/><ROW RowState="13" ACCOUNT_ID="YSW" ACC_CODE_CODE="11011" ACC_CODE_IID="104824663732783567949530" ACC_CODE_NAME="11011 财政专户存款" AMOUNT="11" BILL_SOURCE="00" BK_CODE="00015" BK_DATE="20080526" BK_TYPE="0" BK_TYPENAME="? CO_CODE="000" DESCPT="非税待查收入日报(光大银行)" FISCAL="2007" IID="10111834733188580568430" INPUTOR="sa" INPUTOR_NAME="系统管理员" IN_ACCOUNT_CODE="01090517900120105114338" IN_ACCOUNT_IID="104821544733027385249210" IN_BANK_NAME="北京银行海淀路支行" IN_CO_IID="104821544733027383718750" IN_CO_NAME="北京正元伟业科技发展有限公司" LB01="" LB03="" LB04="" LB05="" LB06="" LB07="" LB08="" LB09="" LB10="" LB11="" LB12="" LB13="" LB14="" LB15="" LB16="" LB17="" LB18="" LB19="" LB20="" OUT_ACCOUNT_CODE="0200001409014420374" OUT_ACCOUNT_IID="1048246204732884367920000" OUT_BANK_NAME="工行百万庄支行" OUT_CO_IID="1048246112732779624417500" OUT_CO_NAME="北京市财政局" YSW_IID=""/><ROW RowState="12" ACCOUNT_ID="YSW" ACC_CODE_CODE="11011" ACC_CODE_IID="104824663732783567949530" ACC_CODE_NAME="11011 财政专户存款" AMOUNT="11" BILL_SOURCE="00" BK_CODE="00015" BK_DATE="20080526" BK_TYPE="0" BK_TYPENAME="? CO_CODE="000" DESCPT="非税待查收入日报(光大银行)" FISCAL="2007" IID="10111834733188580568430" INPUTOR="sa" INPUTOR_NAME="系统管理员" IN_ACCOUNT_CODE="01090517900120105114338" IN_ACCOUNT_IID="104821544733027385249210" IN_BANK_NAME="北京银行海淀路支行" IN_CO_IID="104821544733027383718750" IN_CO_NAME="北京正元伟业科技发展有限公司" LB01="" LB03="" LB04="" LB05="" LB06="104821544733027383718750" LB07="" LB08="" LB09="" LB10="" LB11="" LB12="" LB13="105001" LB14="" LB15="" LB16="" LB17="" LB18="" LB19="" LB20="" OUT_ACCOUNT_CODE="0200001409014420374" OUT_ACCOUNT_IID="1048246204732884367920000" OUT_BANK_NAME="工行百万庄支行" OUT_CO_IID="1048246112732779624417500" OUT_CO_NAME="北京市财政局" YSW_IID="105001"/></ROWDATA></DATAPACKET>
      

  2.   

    你想看什么??xml直接拷贝出来看啊
      

  3.   

    求助啊,大家看看拉,为什么会是nil??谢谢!!!!
      

  4.   

    BK_TYPENAME="? CO_CODE="000" FISCAL="2007" 
      

  5.   

    那里不对了,下面这个xml可以的:<?xml version="1.0" standalone="yes"?>  
    <DATAPACKET Version="2.0">
    <METADATA><FIELDS>
    <FIELD attrname="ACCOUNT_ID" fieldtype="string" WIDTH="30"/><FIELD attrname="CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="COMMENTS" fieldtype="string" WIDTH="200"/><FIELD attrname="CO_CODE" fieldtype="string" WIDTH="30"/><FIELD attrname="CO_IID" fieldtype="string" WIDTH="60"/><FIELD attrname="FISCAL" fieldtype="i4"/><FIELD attrname="IS_FREEZED" fieldtype="string" WIDTH="1"/><FIELD attrname="IS_LOWEST" fieldtype="string" WIDTH="1"/><FIELD attrname="LEVEL_INDEX" fieldtype="i4"/><FIELD attrname="NAME" fieldtype="string" WIDTH="200"/><FIELD attrname="REC_NO" fieldtype="i4"/><FIELD attrname="UP_CODE" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE1" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE10" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE2" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE3" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE4" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE5" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE6" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE7" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE8" fieldtype="string" WIDTH="60"/><FIELD attrname="UP_CODE9" fieldtype="string" WIDTH="60"/>
    </FIELDS><PARAMS CHANGE_LOG="2 1 8"/></METADATA>
    <ROWDATA>
    <ROW RowState="1" ACCOUNT_ID="YSW" CODE="000" COMMENTS="" CO_CODE="000" CO_IID="1048246112732779624417500" FISCAL="2007" IS_FREEZED="" IS_LOWEST="Y" LEVEL_INDEX="1" NAME="北京市财政局" REC_NO="1" UP_CODE="" UP_CODE1="" UP_CODE10="" UP_CODE2="" UP_CODE3="" UP_CODE4="" UP_CODE5="" UP_CODE6="" UP_CODE7="" UP_CODE8="" UP_CODE9=""/><ROW RowState="8" ACCOUNT_ID="YSW" CODE="000" COMMENTS="" CO_CODE="000" CO_IID="1048246112732779624417500" FISCAL="2007" IS_FREEZED="" IS_LOWEST="Y" LEVEL_INDEX="1" NAME="北京市财政局11" REC_NO="1" UP_CODE="" UP_CODE1="" UP_CODE10="" UP_CODE2="" UP_CODE3="" UP_CODE4="" UP_CODE5="" UP_CODE6="" UP_CODE7="" UP_CODE8="" UP_CODE9=""/>
    </ROWDATA></DATAPACKET>
      

  6.   

    谢谢啊,这个xml自动生成的,没想到还会有这种东西!!!!多谢多谢!!!