473,324 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

how to save data in xml files

hi there...

can anyone help me?
i'm trying to create a program that will save the information that i insert into xml files using asp.

but, there is an error occur when i'm trying to save the data.

this is my code:
<%

Function SaveData(strXMLFilePath, strFileName)

'Declare local variables.
Dim objXML
Dim objRoot
Dim objField
Dim objFieldValue
Dim objattID
Dim objattTabOrder
Dim objPI
Dim x

Set objXML = server.CreateObject("Microsoft.XMLDOM")
objXML.preserveWhiteSpace = False

Set objRoot = objXML.createElement("Resource_Repository")
objXML.appendChild objRoot

Set objResource = objXML.createElement("Resource")

Set objText = objXML.createElement("text")
objText.Text = Request.Form("description")
objResource.appendChild objText
Response.Write(objText.Text)

Set objLink = objXML.createElement("Link")
objResource.appendChild objLink

Set objUrl = objXML.createElement("url")

Set objLineText = objXML.createElement("linetext")
objLineText.Text = Request.Form("title")
objLink.appendChild objLineText

Set objSize = objXML.createElement("Size")
objSize.Text = Request.Form("size")
objResource.appendChild objSize

objXML.insertBefore objPI, objXML.childNodes(0)

objXML.save strXMLFilePath & "\" & strFileName

Set objRoot = Nothing
Set objResource = Nothing
Set objText = Nothing
Set objLink = Nothing
Set objUrl = Nothing
Set objLineText = Nothing
Set objSize = Nothing
End Function

On Error Resume Next

SaveFormData "C:\Inetpub\wwwroot\website\xml\5\","resources.xml "

If err.number <> 0 then
Response.write("Errors occurred while saving data.")
Else
Response.write("<center><h2>Data Entry Successful</h2><P>The resource has been successfully added in the database.</center> ")
End If
%>


i don't have any idea how to solve it..
Jul 26 '06 #1
3 9418
danp129
323 Expert 256MB
Make sure the filepath you are saving to allows write access to iuser_xxxx or whatever account your web service is running.
Jul 31 '06 #2
Hi from buenos aires.
My name's Martin. I'm a web apps developer since 1996

there you have to ways to solve this task. From another point of view.

one - create a string of the xml you are creating, using your own tags <x></x> and not XMLDOM object, and then use filesystemobject to save (and or to append to xml file, which is a text file after all). Easy way. You know the XML file structure, ok?

two - save it to a database too. For example ms access or ms excel (you don't have to have office installed to use and msaccess or excel database. It's free. Then use a recordset to retrieve records and use it's save as XML method using ADO and XMLDOM Object together. This way you can have an emergency copy in another format than XML in access or excel. I prefer this way always. It's fast and reliable. The last application I was asked to develope is completly SQLServer/ASP/ADO/XML/XSL/HTML/Javascript/Ajax.

Hope it can help you.

best wishes
:rolleyes:
hi there...

can anyone help me?
i'm trying to create a program that will save the information that i insert into xml files using asp.

but, there is an error occur when i'm trying to save the data.

this is my code:
<%

Function SaveData(strXMLFilePath, strFileName)

'Declare local variables.
Dim objXML
Dim objRoot
Dim objField
Dim objFieldValue
Dim objattID
Dim objattTabOrder
Dim objPI
Dim x

Set objXML = server.CreateObject("Microsoft.XMLDOM")
objXML.preserveWhiteSpace = False

Set objRoot = objXML.createElement("Resource_Repository")
objXML.appendChild objRoot

Set objResource = objXML.createElement("Resource")

Set objText = objXML.createElement("text")
objText.Text = Request.Form("description")
objResource.appendChild objText
Response.Write(objText.Text)

Set objLink = objXML.createElement("Link")
objResource.appendChild objLink

Set objUrl = objXML.createElement("url")

Set objLineText = objXML.createElement("linetext")
objLineText.Text = Request.Form("title")
objLink.appendChild objLineText

Set objSize = objXML.createElement("Size")
objSize.Text = Request.Form("size")
objResource.appendChild objSize

objXML.insertBefore objPI, objXML.childNodes(0)

objXML.save strXMLFilePath & "\" & strFileName

Set objRoot = Nothing
Set objResource = Nothing
Set objText = Nothing
Set objLink = Nothing
Set objUrl = Nothing
Set objLineText = Nothing
Set objSize = Nothing
End Function

On Error Resume Next

SaveFormData "C:\Inetpub\wwwroot\website\xml\5\","resources.xml "

If err.number <> 0 then
Response.write("Errors occurred while saving data.")
Else
Response.write("<center><h2>Data Entry Successful</h2><P>The resource has been successfully added in the database.</center> ")
End If
%>


i don't have any idea how to solve it..
Aug 2 '06 #3
i think your function name which you define is different with which you call
SaveData vs. SaveFormData
Oct 25 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Shakil Khan | last post by:
Hi there ... My question is about Meta Data which is automatically saved with files. For example,when an MS Office Documents is saved, it automaticaly save some extra information with the file...
0
by: Shakil Khan | last post by:
Hi there ... My question is about Meta Data which is automatically saved with some files. For example,when an MS Office Documents is saved, it automaticaly save some extra information with the...
3
by: GMane Python | last post by:
Hello All. I have a program that downloads 'gigabytes' of Axis NetCam photos per day. Right now, I set up the process to put the images into a queue, and every 30 or so seconds, 'pop' them from...
5
by: kevin | last post by:
Hi, Any help with this would be really appreciated! I'm trying to download a file from a remote server. The access permissions is okay but the problem I'm facing is that the file is getting...
4
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a datagrid .The user then selects to save the file as a...
2
by: Scott M. Lyon | last post by:
I'm working on a WinForm application, and recently was informed that I need to create an "Export" function for the data (stored in SQL Server), in a specific (TXT, tab delimited) format. I'd...
1
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image...
4
by: kev | last post by:
Hi folks, I have created a database to store information on equipments. During the first level of registration, there is a form that i need the user to fill up details on the equipment testing....
5
by: countnazgul | last post by:
Hello, I've got very odd problem. I use windows application to store files in data base (MySql) and then to extract this files from data base and save it on hdd. But when i save them back to hdd...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.