I need help with this....
I have Excel file with data.
And I need to export it into XMLfile, using XML Literals in VB.NET
I need some XML-file a a result:
<?xml version="1.0" standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://...">
<soapenv:Header/>
<soapenv:Body xmlns:wsu="http://....xsd">
<Header>
<Verb>cancel</Verb>
</Header>
<Request>
<ID>VALUE-1</ID>
<ID>VALUE-2</ID>
<ID>VALUE-3</ID>
......
</Request>
</soapenv:Body>
</soapenv:Envelope>
Where VALUE-1, VALUE-2,....and so on - I get them from Cells with Ron Numer i and column Number = 2. In VB.NET in Loop I did this like:
While Not this condition
While Not (String.IsNullOrEmpty(Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet.Cells(iRow, 1).Value))
'Check next condition with IF
If LCase(Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet.Cells(iRow, 25).Value) = "y" Then
'Add XElement object into another one XML Element from main XDocument
objRequestCANCEL.Add(objIDCANCEL)
'Add Value for this new Element
objIDCANCEL.Value = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet.Cells(iRow, 2).Value
End If
'Go to next Row and do the same - add XELement if condition is OK here
iRow = iRow + 1
End While
Here objIDCANCEL As XElement in main XDocument I used in this case XElements like Variables.But Now I need something like creation document without variables like this:
Dim XDoc As XDocument = <?xml version="1.0" standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://...">
<soapenv:Header/>
<soapenv:Body xmlns:wsu="http://....xsd">
<Header>
<Verb>create</Verb>
<ID><%= varValue %> </ID>
.....HERE I NEED ADD IN LOOP ALL VALUES FROM ALL ROWS IN EXCEL FILE.....
</Header>
<Request>
</Request>
</RequestMessage>
</soapenv:Body>
</soapenv:Envelope>
Write me please, how can I re-write this Loop here ?
Here is a simple example using LINQ and a worksheet to read out the first column (
1) of the rows1 .. 3and populate some XML literals:Output then is e.g.
Adapt that to your XML format and Excel sheet contents as needed.