求助:生成xml文件怎样才能在每一个要素之后都加上一个vbcrlf实现回车 空行呢?
代码如下:
Dim xls As String = "D:/收案信息.xls"
Dim book As new XLS.Book(xls)
Dim sheet As XLS.Sheet= book.Sheets(0)
Dim xml As String = "D:/收案信息.xml"
Try
Dim writer As New Xml.XmlTextWriter(xml, System.Text.Encoding.GetEncoding("utf-8"))
'书写根元素()
writer.WriteStartElement("case")
For i As Integer = 1 To sheet.Rows.count -1
'添加次级元素
writer.WriteStartElement("caseRegistration")
For j As Integer = 0 To sheet.Cols.count -1
'添加子元素()
writer.WriteElementString(sheet(0,j).value,sheet(i,j).value)
Next
'关闭次级元素DatabaseSetting
writer.WriteEndElement()
Next
'关闭根元素
writer.WriteFullEndElement()
'将XML写入文件并关闭writer
writer.Close()
Catch ex As Exception
MsgBox(ex.Message & vbCrLf & ex.StackTrace)
End Try
生成后的效果为:
<case><caseRegistration><suitDocNumber>1</suitDocNumber><number1>221</number1><name1>22</name1><submittedDate>2016/10/26</submittedDate><number>222</number><name>22</name><suggestedProcedure>普通程序</suggestedProcedure><penalty>死刑</penalty><minDuration>2</minDuration><maxDuration>2</maxDuration><involvedAmount>2</involvedAmount><isTeen>1</isTeen><description>222</description><path>2222</path></caseRegistration></case>
怎么样才能实现为下面的格式呢?
<case>
<caseRegistration>
<suitDocNumber>1</suitDocNumber>
<number1>221</number1>
<name1>22</name1>
<submittedDate>2016/10/26</submittedDate>
<number>222</number>
<name>22</name>
<suggestedProcedure>普通程序</suggestedProcedure>
<penalty>死刑</penalty>
<minDuration>2</minDuration>
<maxDuration>2</maxDuration>
<involvedAmount>2</involvedAmount>
<isTeen>1</isTeen>
<description>222</description>
<path>2222</path>
</caseRegistration>
</case>
[此贴子已经被作者于2016/10/26 13:50:01编辑过]