写写程序,一种成就的感觉

写写程序,一种成就的感觉

导航

生成xml

Posted on 2010-06-03 12:05  hateyoucode  阅读(190)  评论(0编辑  收藏  举报

<%
bitFileExists=true
Dim   strFilename,strXMLFile
  strFilename   =   "test.xml "
  strXMLFile=server.mapPath(strFilename)
  set   oXML   =   server.createObject( "Microsoft.XMLDOM ")
  oXML.async   =   False
  'oXML.load(strXMLFile)
  'oXML.loadXML   " <?xml   version= " "1.0 " "   encoding= " "gb2312 " "   ?> "
  If   bitFileExists   Then
    set   oXMLf=oXML.appendChild(oXML.createElement( "Server1 "))
    set   oXMLs2=oXMLf.appendChild(oXML.createElement( "Server2 "))
  End   If
  for   i=0   to   9
  set   oXMLRec   =   oXMLs2.appendChild(oXML.createElement( "Host "))
  Set   hostnameAtt   =   oXML.createAttribute( "id ")
  hostnameAtt.Text   =   i
  oXMLRec.attributes.setNamedItem   hostnameAtt
  next
 
  set   oProcess=oXML.createProcessingInstruction( "xml ",   "version= '1.0 '   encoding= 'gb2312 ' ")
  oXML.insertBefore   oProcess,oXML.childnodes(0)
 
  oXML.save   strXMLFile
  set   oXML   =   nothing

%>