Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

append an entry into an xml file - newbeeeeeeee

Status
Not open for further replies.

Trebor100

Programmer
Mar 14, 2006
90
GB
Hi all - am stuck on the server side of trying to write off an xml file. my current client side code is as follows:

<html>
<head>
<script type="text/javascript">
function storesomething()
{
var objHTTP, strResult, pd;
objHTTP = new ActiveXObject('Microsoft.XMLHTTP');
objHTTP.Open('POST',"Store.asp",false);
objHTTP.setRequestHeader('Content-Type','application/x- pd = "id=4;title='teach ya self xml';url=' pd = escape(pd);
objHTTP.send(pd);
strResult = objHTTP.responseText;
alert(strResult);
}
</script>
</head>
<body>
<form ID="Form1">
<input type="button" onclick="storesomething()" value="write xml" ID="Button1" NAME="Button1">
</form>
</body>
</html>

All i want to do is apend the data passed to it into a guide.xml file. any help would b much appriciated as im soo stuck atm.
 
Just to clarify... is this file guide.xml on the server? ... and you want to modify the file with an ASP named Store.asp ? Is that correct?

 
[1] Have you seen jpadie's revised version in javascript forum which is correct in practice?
>pd = "id=4;title='teach ya self xml';url='www.wible.com'";
>pd = escape(pd);
[tt]pd="id=4&title="+escape('teach ya self xml')+"&url=www.wible.com"[/tt]

[2] The rest of what you want to do server-side follow steps like this.
[2.1] From the request object, read all the name/value pairs. This is common server-side task (not necessarily related to xml.)
[2.2] Instantiate a DOMDocument object and load server-side the guide.xml. (Check out DOMDocument load method.)
[2.3] You have to decide where and how you want to do with the name/value pairs. Nobody can help you here. It is the semantic of post data of which only you and your users know.
[2.4] From the loaded document (guide.xml), locate the places where you want to add/modify. (Check out XPath documentation.)
[2.5] Use again DOMDocument's many methods to createElement, setAttribute,...to modify the document in the memory.
[2.6] After all that done, use .save method to save a hard copy of guide.xml again.

If you know near to none of all these practical matters, you should not cry out being stuck. You should read the documentation or samples out there. The documentation of methods of DOMDocument starts out here.
The documentation is your only friend.
 
Sheco - guide.xml is on the server in the same location as store.asp

Cheers for the pointers tsuji - will start working through those steps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top