在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
文件格式为: Day 制1課 U12 ASSY01 Wrist 1009 0 2018/05/18 09:35:59 Day 制1課 U12 ASSY02 Wrist 1010 0 2018/05/18 09:36:01 Day 制1課 U12 ASSY03 Wrist 1011 0 2018/05/18 09:36:03 Day 制1課 U12 ASSY04 Wrist 1012 0 2018/05/18 09:36:05 Day 制1課 U12 ASSY05 Wrist 1013 0 2018/05/18 09:36:07 Day 制1課 U12 ASSY06 Wrist 1014 0 2018/05/18 09:36:10 Day 制1課 U12 ASSY07 Wrist 1015 0 2018/05/18 09:36:12 Day 制1課 U12 ASSY08 Wrist 1016 0 2018/05/18 09:36:14 Day 制1課 U12 ASSY09 Wrist 1017 0 2018/05/18 09:36:16 2.把此文件转成XML(用Delphi7): procedure TForm1.Button1Click(Sender: TObject); var lst,lstfield :TStringList; xml:TXMLDocument; node :IXMLNode; i,j:integer; begin xml := TXMLDocument.Create(nil); try xml.Active := True; xml.Version := '1.0'; xml.Encoding := 'UTF-8'; xml.DocumentElement := xml.CreateElement('ESDDATA','ESD'); xml.Options:=[doNodeAutoIndent]; xml.NodeIndentStr :=#9; lstfield := TStringList.Create; try lst := TStringList.Create; try lst.LoadFromFile('ESDStatus.txt'); Memo1.Text := lst.Text; for i:=0 to lst.Count-1 do begin lstfield.Clear; ExtractStrings([Char(VK_TAB)],[' '], PChar(lst[i]), lstfield) ; if lstfield.Count>0 then begin node := xml.DocumentElement.AddChild('item'); {node.AddChild('SHIFT_NAME').Text :=lstfield[0]; --加子元素 node.AddChild('PRODUCT_ROOM').Text :=lstfield[1]; node.AddChild('PDLINE_NAME').Text :=lstfield[2]; node.AddChild('POSITION').Text :=lstfield[3]; node.AddChild('CATEGORY').Text :=lstfield[4]; node.AddChild('NO').Text :=lstfield[5]; node.AddChild('STATUS').Text :=lstfield[6]; node.AddChild('PROCESSTIME').Text :=lstfield[7];} node.Attributes['SHIFT_NAME']:= lstfield[0]; //增加元素属性 node.Attributes['PRODUCT_ROOM']:= lstfield[1]; node.Attributes['PDLINE_NAME']:= lstfield[2]; node.Attributes['POSITION']:= lstfield[3]; node.Attributes['CATEGORY']:= lstfield[4]; node.Attributes['NO']:= lstfield[5]; node.Attributes['STATUS']:= lstfield[6]; node.Attributes['PROCESSTIME']:= lstfield[7]; end; end; finally lst.Free; end; finally lstfield.Free; end; Memo2.Lines.Text:= xml.XML.Text; finally node:=nil; xml.Active := false; xml.Free; end; end; 3 生成子元素的内容为: <?xml version="1.0" encoding="UTF-8"?> <ESDDATA xmlns="ESD"> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY01</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1009</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:35:59</PROCESSTIME> </item> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY02</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1010</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:36:01</PROCESSTIME> </item> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY03</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1011</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:36:03</PROCESSTIME> </item> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY04</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1012</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:36:05</PROCESSTIME> </item> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY05</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1013</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:36:07</PROCESSTIME> </item> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY06</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1014</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:36:10</PROCESSTIME> </item> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY07</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1015</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:36:12</PROCESSTIME> </item> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY08</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1016</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:36:14</PROCESSTIME> </item> <item> <SHIFT_NAME>Day</SHIFT_NAME> <PRODUCT_ROOM>鍒?瑾?/PRODUCT_ROOM> <PDLINE_NAME>U12</PDLINE_NAME> <POSITION>ASSY09</POSITION> <CATEGORY>Wrist</CATEGORY> <NO>1017</NO> <STATUS>0</STATUS> <PROCESSTIME>2018/05/18 09:36:16</PROCESSTIME> </item> </ESDDATA>
4 生成元素属性内容为: <?xml version="1.0" encoding="UTF-8"?> <ESDDATA xmlns="ESD"> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY01" CATEGORY="Wrist" NO="1009" STATUS="0" PROCESSTIME="2018/05/18 09:35:59"/> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY02" CATEGORY="Wrist" NO="1010" STATUS="0" PROCESSTIME="2018/05/18 09:36:01"/> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY03" CATEGORY="Wrist" NO="1011" STATUS="0" PROCESSTIME="2018/05/18 09:36:03"/> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY04" CATEGORY="Wrist" NO="1012" STATUS="0" PROCESSTIME="2018/05/18 09:36:05"/> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY05" CATEGORY="Wrist" NO="1013" STATUS="0" PROCESSTIME="2018/05/18 09:36:07"/> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY06" CATEGORY="Wrist" NO="1014" STATUS="0" PROCESSTIME="2018/05/18 09:36:10"/> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY07" CATEGORY="Wrist" NO="1015" STATUS="0" PROCESSTIME="2018/05/18 09:36:12"/> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY08" CATEGORY="Wrist" NO="1016" STATUS="0" PROCESSTIME="2018/05/18 09:36:14"/> <item SHIFT_NAME="Day" PRODUCT_ROOM="鍒?瑾? PDLINE_NAME="U12" POSITION="ASSY09" CATEGORY="Wrist" NO="1017" STATUS="0" PROCESSTIME="2018/05/18 09:36:16"/> </ESDDATA>
5:可以把以上的内容做为参数传给数据库进行处理,保证事物的原子性(具休调用待后续提供). |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论