我需要这方面的帮助......我有 Excel 文件和数据。我需要将它导出到 XMLfile 中,使用 VB.NET 中的 XML Literals
我需要一些 XML 文件结果:
<?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>
其中VALUE-1,VALUE-2,....等等-我从具有Ron Numer i和列号= 2的单元格中获取它们。在循环中的VB.NET中,我这样做了:
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
这里 objIDCANCEL As XElement in main XDocument 我在这种情况下使用了 XElements like Variables.But 现在我需要像创建文档这样的东西,没有像这样的变量:
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>
请写信给我,我怎样才能在这里重写这个循环?