如何使用vb在文件中保存xml

时间:2012-05-14 11:38:00

标签: xml vb.net json

我已经将josn对象转换为xmlDocumet n想要将这个xmlDocumet保存在计算机上,比如abc.xml使用vb请求帮助。文件太大了我无法阅读其个别标签n友好帮助

Private Function JsonToX() As XDocument
    Dim xmlDoc As XDocument
    Dim EventId As String
    EventId = GetEventID()
    Dim httpWebRequest As HttpWebRequest = WebRequest.Create(url)
    httpWebRequest.Method = WebRequestMethods.Http.Get
    httpWebRequest.Accept = "application/json"
    Dim response As HttpWebResponse
    response = httpWebRequest.GetResponse()
    Dim ResponseStream As Stream = response.GetResponseStream()
    Dim StreamReader As New StreamReader(ResponseStream)
    Dim Text As String = StreamReader.ReadToEnd()
    'because the origional JSON string has multiple root's this needs to be added
    Dim jsonhtml As String = "{BFBC2_GlobalStats:"
    jsonhtml += Text + "}"
    xmlDoc = JsonConvert.DeserializeXNode(jsonhtml)
    ' want to save xmldoc in a file  xmlDoc.Save("abc.xml") not working
    Return xmlDoc
End Function

0 个答案:

没有答案