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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to acheive object.xml = someXml, where someXML is html

Status
Not open for further replies.

iporter

Programmer
Joined
Mar 24, 2004
Messages
2
Location
GB
Hi - I'm builing a content management system, so I have xml along the lines of:
Code:
<site>
<page id="1">
  <title></title>
  <content>
    <div id="content"><p>This is my content</p></div>
  </content>
</page>
</site>

So I use javascript on the server side to output the <content> element:
Code:
Response.Write(webpage.selecSingeNode("content").xml);

I then edit that content & try to save it back to the XML file.

On the client-side:
Code:
var xml = document.getElementById('content').innerHTML;

I pass this to a hidden <input>, and submit the form. On the server-side I then:
Code:
var newContent = "<content>" + Request.Form("contentContainer") + "</content>";
var newContentFile = new ActiveXObject("Microsoft.XMLDOM");
newContentFile.async = false;
newContentFile.loadXML(newContent);
newContent = newContentFile.documentElement;

But then on Response.Write(newContent.xml) i get 'object required'.

What is the proper way of doing this? I feel I should be able to basically do something along the lines of output from file using document.getElementById('content') = object.xml, and then save by doing object.xml = document.getElementById('content') - I want to do it using a proper, standard method.

object.xml is of course read-only. Is it something to do with parsing? or httpxml? I'm new to these concepts and using xml.

Thanks a lot all,
Iain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top