你好朋友我正在处理经典的 ASP 项目,我正在使用 XML 文件进行 CRUD 操作。当文件不存在时,可以在其中保存数据但文件已经存在如何在其中追加新记录数据?我的代码:
If Not objFSO.FileExists( xmlFile ) Then
objFSO.CreateTextFile( xmlFile )
set objWrite = objFSO.OpenTextFile( xmlFile, 2 )
objWrite.WriteLine("<?xml version=""1.0"" encoding=""ISO-8859-1""?>")
objWrite.WriteLine(tb & "<Slider>")
objWrite.WriteLine(tb & tb & "<Header>" & Uploader.Form("headerText") & "</Header>")
objWrite.WriteLine(tb & tb & "<Image>" & File.FileName & "</Image>")
objWrite.WriteLine(tb & tb & "<Link>" & Uploader.Form("linkcontentText") & "</Link>")
objWrite.WriteLine(tb & tb & "<Description>" & Uploader.Form("SliderText") & "</Description>")
objWrite.WriteLine(tb & "</Slider>")
End IF
If objFSO.FileExists( xmlFile ) Then
'append code , i have tried this but not working
Set xmlDoc = CreateObject("Scripting.FileSystemObject")
xmlDoc.async = False
xmlDoc.load(Server.MapPath(xmlFile)
Set fieldName = xmlDoc.createElement("Slider")
Set attID = xmlDoc.createAttribute("Header")
Set attID1 = xmlDoc.createAttribute("Image")
Set attID2 = xmlDoc.createAttribute("Link")
Set attID3 = xmlDoc.createAttribute("Description")
attID.Text = Uploader.Form("headerText")
attID1.Text = File.FileName
attID2.Text = Uploader.Form("linkcontentText")
attID3.Text = Uploader.Form("SliderText")
fieldName.setAttributeNode attID
fieldName.setAttributeNode attID1
fieldName.setAttributeNode attID2
fieldName.setAttributeNode attID3
'xmlDoc.a
'xmlDoc.Save(Server.MapPath("menu1.xml"))
End If
请建议我一些解决方案。