by Microsoft. simple sample
How to get it done in C#
Another good example from Microsoft.
Tuesday, 31 May 2011
create xml doc in vb.net
Public Function next_ten_dates(ByVal startDate As Date) As String
Dim xDoc As New XmlDocument
Dim xNode As XmlElement
Dim newAtt As XmlAttribute
Dim xDocRoot As XmlElement = xDoc.CreateElement("dates")
xDoc.AppendChild(xDocRoot)
For i As Integer = 0 To 10
Dim xdate As XmlNode = xDoc.CreateElement("date")
xdate.InnerText = getJapaneseDate(startDate.AddDays(i))
newAtt = xDoc.CreateAttribute("daysinmonth")
Dim datesinmonth = startDate.DaysInMonth(startDate.Year, _
startDate.Month)
newAtt.Value = datesinmonth.ToString()
xdate.Attributes.Append(newAtt)
xDocRoot.AppendChild(xdate)
Next
Dim XMLString As String = ""
Dim sw As New StringWriter()
Dim xw As New XmlTextWriter(sw)
xDoc.WriteTo(xw)
XMLString = sw.ToString()
next_ten_dates = XMLString
End Function
Dim xDoc As New XmlDocument
Dim xNode As XmlElement
Dim newAtt As XmlAttribute
Dim xDocRoot As XmlElement = xDoc.CreateElement("dates")
xDoc.AppendChild(xDocRoot)
For i As Integer = 0 To 10
Dim xdate As XmlNode = xDoc.CreateElement("date")
xdate.InnerText = getJapaneseDate(startDate.AddDays(i))
newAtt = xDoc.CreateAttribute("daysinmonth")
Dim datesinmonth = startDate.DaysInMonth(startDate.Year, _
startDate.Month)
newAtt.Value = datesinmonth.ToString()
xdate.Attributes.Append(newAtt)
xDocRoot.AppendChild(xdate)
Next
Dim XMLString As String = ""
Dim sw As New StringWriter()
Dim xw As New XmlTextWriter(sw)
xDoc.WriteTo(xw)
XMLString = sw.ToString()
next_ten_dates = XMLString
End Function
Subscribe to:
Posts (Atom)