有一个xml文件:user.xml  格式为:
<user>
  <userId>
  </userId>
  <userId>
  </userId>
</user>
就是想用来存一个string型的userId请问怎么用asp打开该文件,向里面添加一条记录怎么用asp.net打开该文见,找到这条记录,并删除该记录谢谢

解决方案 »

  1.   

    用selectsinglenode
    删除是操作xml的节点
    具体看看msdn的例子
      

  2.   

    http://blog.csdn.net/lizanhong/archive/2004/06/23/24374.aspx
      

  3.   

    asp(vbscript)
    <%@ Language=VBScript %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
    <body>
    Hello World!
    <%
    set xmlData = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
    xmlData.async = false
    xmlData.load("http://localhost/data.xml")
    set objNode = xmlData.selectSingleNode("/user")
    objNode.removeChild(objNode.childNodes(0))
    for i = 0 to objNode.childNodes.length-1
    Response.Write i
    next
    xmlData.save(server.MapPath("./") & "\result.xml")
    %></body>
    </html>
    asp.net(.vb)Dim objxml As System.Xml.XmlDocument
    Dim objNode As System.Xml.XmlNode
    objxml.Load("http://localhost/data.xml")
    objNode = objxml.SelectSingleNode("/user")
    objNode.RemoveChild(objNode.ChildNodes(0))
    objxml.Save(Server.MapPath("./") & "\result.xml")xml:
    data.xml
    <user>
      <userId>
      </userId>
      <userId>
      </userId>
    </user>