I need to make a simple modification to a couple thousand .xml files that are used as recipes for a machine I have. I've done this in the past with .dat files that were just text using a vbscript that created a colum for each file that started with the file name and then each row had the text that was on each line. this worked great but the .dat files only had 10 rows of text without symbols OR anything crazy. I'm trying to do the same thing with the .xml files I have but they have a lot of extra text that is not being transfered to the excel file. I'll post the vbscript that works well for the .dat file and also an example of the xml file I need to get into excell.
This is what is inside the xml file and I just need to change one of the values (spin speed) on thousands of files. What I've done in the past is converted many text files to rows inside of excel, made modifications to the data and then convertd them back to text files ending in .dat. This was amazing and worked really well. However that same script doesn't work for this .xml file. Well it actually worKs but I only get the name not the valves below the name. I can post the script I'm using as well and perhaps someone can help me get this done. the script that works for simple .dat files is below the sample .xml text.
I really only need a script that will pull out the numbers between ,<value>X</Value> I need the X's in a column that I can modify. Then I'll need to take that modified data and create a .xml file that looks like the file below with the new data.
thanks,
Dave
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="recipe.xsl"?>
<TAGLIST>
<TAG>
<NAME>hmi_Spin_at_Dip</NAME>
<VALUE>1</VALUE>
</TAG>
<TAG>
<NAME>hmi_Hopper_Lower</NAME>
<VALUE>1</VALUE>
</TAG>
<TAG>
<NAME>hmi_Double_Cycle</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Double_Dip</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Numb_Dump</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Batch_Weight</NAME>
<VALUE>150</VALUE>
</TAG>
<TAG>
<NAME>hmi_Dip_Speed</NAME>
<VALUE>10</VALUE>
</TAG>
<TAG>
<NAME>hmi_Spin_Speed</NAME>
<VALUE>300</VALUE>
</TAG>
<TAG>
<NAME>hmi_Dip_Time</NAME>
<VALUE>10</VALUE>
</TAG>
<TAG>
<NAME>hmi_Spin_Time</NAME>
<VALUE>15</VALUE>
</TAG>
<TAG>
<NAME>hmi_Number_of_Spins</NAME>
<VALUE>2</VALUE>
</TAG>
<TAG>
<NAME>hmi_InVibe_Speed</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Conveyor_Speed</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Customer_Name</NAME>
<VALUE>slidematic</VALUE>
</TAG>
<TAG>
<NAME>hmi_Part_Description</NAME>
<VALUE>m8x1.25x56mm</VALUE>
</TAG>
<TAG>
<NAME>Recipe_Top_Coat_Type</NAME>
<VALUE>black tnt-15</VALUE>
</TAG>
</TAGLIST>
*************************SCRIPT THAT WORKS GREAT FOR CONVERTING .DAT FILES TO COLUMNS WITHIN AN EXCEL SHEET*********
Sub import_text_files()
Dim sh As Worksheet, wPath As String, wFile As String
Dim w2 As Workbook, sh2 As Worksheet, k As Long, lr2 As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set sh = Sheets("Sheet1")
sh.Cells.Clear
k = 1
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Selecciona una carpeta"
.AllowMultiSelect = False
.InitialFileName = ThisWorkbook.Path
If .Show <> -1 Then Exit Sub
wPath = .SelectedItems(1)
wFile = Dir(wPath & "\" & "*.dat")
Do While wFile <> ""
Set w2 = Workbooks.Open(wPath & "\" & wFile)
Set sh2 = w2.Sheets(1)
lr2 = sh2.Range("A" & Rows.Count).End(xlUp).Row
sh.Cells(1, k).Value = wFile
sh.Cells(2, k).Resize(lr2).Value = sh2.Range("A1:A" & lr2).Value
k = k + 1
w2.Close False
wFile = Dir()
Loop
End With
MsgBox "End"
End Sub
This is what is inside the xml file and I just need to change one of the values (spin speed) on thousands of files. What I've done in the past is converted many text files to rows inside of excel, made modifications to the data and then convertd them back to text files ending in .dat. This was amazing and worked really well. However that same script doesn't work for this .xml file. Well it actually worKs but I only get the name not the valves below the name. I can post the script I'm using as well and perhaps someone can help me get this done. the script that works for simple .dat files is below the sample .xml text.
I really only need a script that will pull out the numbers between ,<value>X</Value> I need the X's in a column that I can modify. Then I'll need to take that modified data and create a .xml file that looks like the file below with the new data.
thanks,
Dave
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="recipe.xsl"?>
<TAGLIST>
<TAG>
<NAME>hmi_Spin_at_Dip</NAME>
<VALUE>1</VALUE>
</TAG>
<TAG>
<NAME>hmi_Hopper_Lower</NAME>
<VALUE>1</VALUE>
</TAG>
<TAG>
<NAME>hmi_Double_Cycle</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Double_Dip</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Numb_Dump</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Batch_Weight</NAME>
<VALUE>150</VALUE>
</TAG>
<TAG>
<NAME>hmi_Dip_Speed</NAME>
<VALUE>10</VALUE>
</TAG>
<TAG>
<NAME>hmi_Spin_Speed</NAME>
<VALUE>300</VALUE>
</TAG>
<TAG>
<NAME>hmi_Dip_Time</NAME>
<VALUE>10</VALUE>
</TAG>
<TAG>
<NAME>hmi_Spin_Time</NAME>
<VALUE>15</VALUE>
</TAG>
<TAG>
<NAME>hmi_Number_of_Spins</NAME>
<VALUE>2</VALUE>
</TAG>
<TAG>
<NAME>hmi_InVibe_Speed</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Conveyor_Speed</NAME>
<VALUE>0</VALUE>
</TAG>
<TAG>
<NAME>hmi_Customer_Name</NAME>
<VALUE>slidematic</VALUE>
</TAG>
<TAG>
<NAME>hmi_Part_Description</NAME>
<VALUE>m8x1.25x56mm</VALUE>
</TAG>
<TAG>
<NAME>Recipe_Top_Coat_Type</NAME>
<VALUE>black tnt-15</VALUE>
</TAG>
</TAGLIST>
*************************SCRIPT THAT WORKS GREAT FOR CONVERTING .DAT FILES TO COLUMNS WITHIN AN EXCEL SHEET*********
Sub import_text_files()
Dim sh As Worksheet, wPath As String, wFile As String
Dim w2 As Workbook, sh2 As Worksheet, k As Long, lr2 As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set sh = Sheets("Sheet1")
sh.Cells.Clear
k = 1
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Selecciona una carpeta"
.AllowMultiSelect = False
.InitialFileName = ThisWorkbook.Path
If .Show <> -1 Then Exit Sub
wPath = .SelectedItems(1)
wFile = Dir(wPath & "\" & "*.dat")
Do While wFile <> ""
Set w2 = Workbooks.Open(wPath & "\" & wFile)
Set sh2 = w2.Sheets(1)
lr2 = sh2.Range("A" & Rows.Count).End(xlUp).Row
sh.Cells(1, k).Value = wFile
sh.Cells(2, k).Resize(lr2).Value = sh2.Range("A1:A" & lr2).Value
k = k + 1
w2.Close False
wFile = Dir()
Loop
End With
MsgBox "End"
End Sub