我有这个示例xml文件
<LTRP cd="1">
<Customize>0</Customize>
<Gud>0</Gud>
<Kingaku>64500000</Kingaku>
<Kingaku term="1" year="2017" month="0">0</Kingaku>
</LTRP>
我得到了这个代码 - 假设我已经拥有了所需的数据
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.Indent = True
Dim dsProperty As New DsikopgmProperty
Dim xmlFileName As String = "filename"
' Create XmlWriter.
Using writer As XmlWriter = XmlWriter.Create("C:\FILES\" + xmlFileName, settings)
' Begin writing.
writer.WriteStartDocument()
For Each record In records
writer.WriteStartElement("LTRP cd", dsrecords.BunruiCd)
writer.WriteElementString("Customize", "")
writer.WriteElementString("Gud", "0")
writer.WriteEndElement()
Next
' End document.
writer.WriteEndElement()
writer.WriteEndDocument()
End Using
我想知道我应该更改代码的哪个特定部分以获得这些输出
<LTRP cd="1">
</LTRP>
<Kingaku term="1" year="2017" month="0">0</Kingaku>
虽然我很喜欢,但任何人都可以告诉我除<>
和greater than
以外我们称之为lesser than
符号吗?
答案 0 :(得分:1)
这是我为提出所需输出而进行的修改
Dim writer As XmlWriter = Nothing
writer = XmlWriter.Create("sampledata.xml")
writer.WriteStartElement("LTRP")
writer.WriteAttributeString("cd", "1")
writer.WriteElementString("Customize", "0")
writer.WriteElementString("Gud", "0")
writer.WriteElementString("Kingaku", "64500000")
writer.WriteStartElement("Kingaku")
writer.WriteAttributeString("term", "1")
writer.WriteAttributeString("year", "2017")
writer.WriteAttributeString("month", "0")
writer.WriteValue("0")
writer.WriteEndElement()
writer.WriteElementString("rate", "10")
writer.WriteEndElement()
writer.Flush()
writer.Close()
对于来源,click here. 感谢@the_lotus发表重要评论。
注意:我只使用常量值进行测试。可以用变量替换它来循环许多记录。