bsbertolani wrote: ↑Fri Jun 10, 2022 4:50 pm
Can you elaborate on the question? For me, it's not clear what should be the result files. Place the example XML file.
But you can read about
XML Module This allow you read the nodes of xml.
Hello !
Sorry for the poorly worded question, I'll explain better.
I received a VBscript from a client where he needs to split one XML file that has one or more itens (paper types).
The script is written to select the XML in a fixed folder and fixed filename (D:\Enfocus\XML_Split\in\OS_25102_dados_ecalc.xml)
them will split in as many XML´s as there are different itens on it, in the test XML there are 2 only, and the output XML´s
are D:\Enfocus\XML_Split\out\25102_1.xml and D:\Enfocus\XML_Split\out\25102_2.xml.
What I need is that the script gets the file from the flow and not a fixed folder and execute the script and outcome the news XMl´s in the flow, but this could be a fixed folder no problem.
I´m new to scripting and I don´t know if there is a variable in Switch Scripter that can handle this in VBScript.
This is the script:
' Is invoked each time a new job arrives in one of the input folders for the flow element.
' The newly arrived job is passed as the second parameter.
Function jobArrived(s, job)
'Abrir XML e gerar outro a partir deste
'Cada Row será um XML. Nome dos XMLS é CNPOARQOS & "_" & sequencial
'---------------------------------
Dim i, strNomeXMLSaida, strXMLEntrada, strLocalXMLSaida, strXML , nometrab
'*************************** PARAMETRIZAR ***************************
strXMLEntrada = "D:\Enfocus\XML_Split\in\OS_25102_dados_ecalc.xml"
strLocalXMLSaida = "D:\Enfocus\XML_Split\out"
'********************************************************************
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load(strXMLEntrada)
Set colNodes = xmlDoc.selectNodes("//Column")
i=1
iArq = 1
For Each objNode in colNodes 'Caminha em cada Column dos nós Row e a variável i controla cada Column
If i = 1 Then 'Coluna CNPOARQOS do XML
strXML = ""
strNomeXMLSaida = objNode.text & "_" & iArq & ".xml" 'Nome do Arquivo padrão: CNPOARQOS & "_" & iArq
iArq = iArq + 1
End If
strXML = strXML& objNode.xml
If i = 22 Then 'Coluna QTDE_TOTAL do XML, última da Row. Zera i para iniciar na primeira coluna da próxima Row e gera arquivo
Set xmlDocSaida = CreateObject("Microsoft.XMLDOM")
xmlDocSaida.loadXML("<Row>" & strXML & "</Row>")
xmlDocSaida.save strLocalXMLSaida & "\" & strNomeXMLSaida
Set xmlDocSaida = Nothing
i = 0 'Inicia o novo nó
End If
i = i + 1
Next
Set xmlDoc = Nothing
job.sendToSingle job.getPath()
End Function
' Is invoked at regular intervals regardless of whether a new job arrived or not.
' The interval can be modified with s.setTimerInterval().
' Function timerFired(s)
' End Function
' Is invoked each time a new webhook request arrives, if the entry point has subscribed to the request.
' The newly arrived request is passed as the second parameter.
' Function webhookTriggered(s, r)
' End Function
Thanks in advance.