本帖最后由 sdwd_lhq 于 2017-3-28 20:34 编辑
帮忙顶,也需要呀
我碰到的ado recorderset 格式的XML数据,没办法写了程序用正则的方法进行了提取
代码如下:While 1
Local $line = FileReadLine($fileXml)
If @error = -1 Then ExitLoop
$line = StringStripWS($line, 3)
If StringLeft($line, 6) = "<z:row" Then
$xml_row = $line& " "
Else
$xml_row = $xml_row & $line&" "
EndIf
;MsgBox(0,"",$xml_row)
If StringRight($xml_row, 3) = "/> " Then
;MsgBox(0,"",$xml_row)
$array = StringRegExp($xml_row, "\S*='(\S*)'", 3)
;_ArrayDisplay($array, "$avArray 为二维数组")
$row_string = ""
For $i = 0 To UBound($array) - 1
If $i = 0 Then
$row_string = '"' & $array[$i] & '"'
Else
$row_string = $row_string & ',"' & $array[$i] & '"'
EndIf
Next
FileWriteLine($fileCsv, $row_string)
FileFlush($fileCsv)
$xml_row=""
EndIf
WEnd
数据格式如下:<z:row TYPE='2' CURDATE='2015-06-22T16:15:22' YEAR='2015' MONTH='6' DAY='22' PFNAME='C45P8防腐' SUMWGT='4711.0100000000002'
JBSJ='45' SUMPS='2' CURPS='4' SAHS='0.80000000000000004' HEHS='0' ZAHS='0' SihSa='0' SERVER='于' USERNAME='建设(集团)有限公司'
USERCHE='吴' JIAOZUBW='3#宿舍楼北楼及中间连廊一层梁' SHUIHB='' TALADU='180' GCNAME='交通学校海运学院迁建项目'
PhbNumber='9' CheTime='2015-06-22T16:10:48' CheNumber='12552' Mat1YQWGT='1411.3' Mat2YQWGT='0' Mat3YQWGT='2000'
Mat4YQWGT='0' Mat5YQWGT='520' Mat6YQWGT='200' Mat7YQWGT='0' Mat8YQWGT='0' Mat9YQWGT='230' mat10YQWGT='328.69999999999999'
Mat11YQWGT='24' Mat12YQWGT='0' Mat16YQWGT='0' Mat17YQWGT='0' Mat18YQWGT='0' Mat1SJWGT='1409' Mat2SJWGT='0' Mat3SJWGT='1996'
Mat4SJWGT='0' Mat5SJWGT='525' Mat6SJWGT='198' Mat7SJWGT='0' Mat8SJWGT='0' Mat9SJWGT='230' Mat10SJWGT='329' Mat11SJWGT='24.010000000000002'
Mat12SJWGT='0' Mat16SJWGT='0' Mat17SJWGT='0' Mat18SJWGT='0' MatName1='沙1' MatName2='0.5石子' MatName3='石子3'
MatName4='石子4' MatName5='水泥1' MatName6='粉煤灰' MatName7='膨胀剂' MatName8='膨胀剂' MatName9='矿粉'
MatName10='水' MatName11='液剂1' MatName12='液剂2' mpjs='0' GZgg='/' GZtype='' GZlong='' SetMJLFS='0' rwID='12'
bsqk='车泵(46)' htbh='' szlb='' gcdz='' id='160457'/>
<z:row TYPE='2' CURDATE='2015-06-22T16:17:09' YEAR='2015' MONTH='6' DAY='22' PFNAME='C45P8防腐' SUMWGT='4702.7299999999996'
JBSJ='45' SUMPS='2' CURPS='5' SAHS='0.80000000000000004' HEHS='0' ZAHS='0' SihSa='0' SERVER='于' USERNAME='建设(集团)有限公司'
USERCHE='吴' JIAOZUBW='3#宿舍楼北楼及中间连廊一层梁' SHUIHB='' TALADU='180' GCNAME='交通学校海运学院迁建项目'
PhbNumber='9' CheTime='2015-06-22T16:10:48' CheNumber='12552' Mat1YQWGT='1411.3' Mat2YQWGT='0' Mat3YQWGT='2000'
Mat4YQWGT='0' Mat5YQWGT='520' Mat6YQWGT='200' Mat7YQWGT='0' Mat8YQWGT='0' Mat9YQWGT='230' mat10YQWGT='328.69999999999999'
Mat11YQWGT='24' Mat12YQWGT='0' Mat16YQWGT='0' Mat17YQWGT='0' Mat18YQWGT='0' Mat1SJWGT='1396' Mat2SJWGT='0' Mat3SJWGT='2000'
Mat4SJWGT='0' Mat5SJWGT='525' Mat6SJWGT='199' Mat7SJWGT='0' Mat8SJWGT='0' Mat9SJWGT='230' Mat10SJWGT='329' Mat11SJWGT='23.73'
Mat12SJWGT='0' Mat16SJWGT='0' Mat17SJWGT='0' Mat18SJWGT='0' MatName1='沙1' MatName2='0.5石子' MatName3='石子3'
MatName4='石子4' MatName5='水泥1' MatName6='粉煤灰' MatName7='膨胀剂' MatName8='膨胀剂' MatName9='矿粉'
MatName10='水' MatName11='液剂1' MatName12='液剂2' mpjs='0' GZgg='/' GZtype='' GZlong='' SetMJLFS='0' rwID='12'
bsqk='车泵(46)' htbh='' szlb='' gcdz='' id='160458'/>
|