<?xml version="1.0" encoding="GBK" ?> 
- <data version="1.0">
  </data>
如何使用vb实现这样的xml格式,解决给高分

解决方案 »

  1.   

    您可以在使用XML DOM模型中的对象在VB中生成XML文件。如下例,您能把文本框Text1中的内容作为一个字符串节点写入XML文件。  Private Sub Command1_Click() Set xmldoc = CreateObject("Msxml2.DOMDocument") Set rootElement = xmldoc.createElement("memo") Set toElement = xmldoc.createElement("to") Set toElementText = xmldoc.createTextNode(Text1.Text) xmldoc.appendChild (rootElement) rootElement.appendChild (toElement) toElement.appendChild (toElementText) xmldoc.Save ("C:\test1.xml") End Sub 详细信息请参考以下链接: Working with XML Document Parts http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmconworkingwithxmldocumentparts.asp  -        微软全球技术中心 VB技术支持 本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款 (http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。 为了为您创建更好的讨论环境,请参加我们的用户满意度调查 (http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。 
      

  2.   

    'test.xml
    Open App.Path & "\text.XML" For Output As #1
    '写入:<?xml version="1.0" encoding="GBK"?>
    Print #1, "<?xml version= " & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "GBK" & Chr(34) & "?>"
    close #1