1 Dim x As XElement = <employee>
2 <id>1id>
3 <name>Maryname>
4 employee>
5 MsgBox(x.ToString())
若不想把XML的文字資料寫死,可以改用Expression:
1 Dim emp As Employee = New Employee()
2 emp.ID = "1"
3 emp.Name = "Mary"
4 Dim x As XElement = <employee>
5 <id><%= emp.ID %>id>
6 <name><%= emp.Name %>name>
7 employee>
8 MsgBox(x.ToString())
Employee類別如下:
1 Class Employee
2 Public ID As Integer
3 Public Name As String
4 End Class
沒有留言:
張貼留言