将前台传递的xml保存为xml文件
//将前台传递的xml保存为xml文件
Sub SaveXml(ByVal dataFileName As String, ByVal dataString As String)
Dim doc As New XmlDocument
doc.Load(Server.MapPath(dataFileName))
doc.SelectSingleNode("//note").InnerXml = dataString
doc.Save(Server.MapPath(dataFileName))
End Sub
//将保存的xml文件转为json对象传递到前台
Function ReturnJson(ByVal dataFileName As String) As String
Dim doc As New XmlDocument
doc.Load(Server.MapPath(dataFileName))
Dim json As String
json = "{["
For i As Integer = 1 To doc.SelectNodes("//user").Count
json += "" + "{" + "'" + doc.SelectSingleNode("//user[" + i.ToString() + "]/name").Name + "':'" + doc.SelectSingleNode("//user[" + i.ToString() + "]/name").InnerText + "',"
json += "'" + doc.SelectSingleNode("//user[" + i.ToString() + "]/email").Name + "':'" + doc.SelectSingleNode("//user[" + i.ToString() + "]/email").InnerText + "',"
json += "'" + doc.SelectSingleNode("//user[" + i.ToString() + "]/info").Name + "':'" + doc.SelectSingleNode("//user[" + i.ToString() + "]/info").InnerText + "'},"
Next
json = json.Substring(0, json.Length - 1)
json = json + "]}"
Return json
End Function