XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 12th, 2003, 04:31 PM
hhibo hhibo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 8 hhibo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
writing to xml-file

Please, can someone help:

I need a script to pass some xml-data from a form and add it to an xml-file.

The script I've been trying out is supposed to get the elements into its right place in the node tree, but it doesn't work.

MSMXL is telling me that "parentNode is null" or object is missing.

This is what the script looks like:

<%@ Language=JScript%>
<%
var personid = Request.querystring("personid");
var comment = Request.querystring("comment");
var refnum = Request.querystring("refnum");
var bind = Request.querystring("bind");
var side = Request.querystring("side");


var xmlDoc=Server.CreateObject("Msxml2.FreeThreadedDOMDocument");
xmlDoc.async="false";
xmlDoc.load(Server.MapPath("person_comment.xml"));
var nodeList = xmlDoc.getElementsByTagName("person_comments");

if (nodeList > 0){
var parentNode = nodeList(0) ;
var person_commentNode = xmlDoc.createElement("person_comment");
var personidNode = xmlDoc.createElement("personid");
var commentNode = xmlDoc.createElement("comment");
var refnumNode = xmlDoc.createElement("refnum");
var bindNode = xmlDoc.createElement("bind");
var sideNode = xmlDoc.createElement("side");

personidNode.text = personid;
commentNode.text = comment;
refnumNode.text = refnum;
bindNode.text= bind;
sideNode.text = side;
root.appendChild(person_commentNode);
person_commentNode.appendChild(personidNode);
person_commentNode.appendChild(commentNode);
person_commentNode.appendChild(refnumNode);
person_commentNode.appendChild(bindNode);
person_commentNode.appendChild(sideNode);

xmlDoc.save(Server.MapPath("person_comment.xml"));
}
%>

The xml-file I'm writing to looks like this:

<?xml version="1.0" encoding="utf-8"?>
<person_comments>
<person_comment><id>1</id><personid></personid><comment>tdddd</comment><refnum>6</refnum><bind></bind><side></side></person_comment>
</peson_comments>

I would be really happy to hear from anyone about this one.

Bente

Reply With Quote
  #2  
Old September 12th, 2003, 08:12 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Two things:
I think
Code:
var parentNode = nodeList(0) ;
should be
Code:
var parentNode = nodeList[0];
but I'm not sure of that.

Also, "root" is undefined, so
Code:
root.appendChild(person_commentNode); 
is going to break. I think you meant parentNode instead of root. You should also move that line after the following 5, otherwise you won't get the result you're expecting.

Reply With Quote
  #3  
Old September 13th, 2003, 07:03 AM
hhibo hhibo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 8 hhibo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you for your help.

Quote:
Originally posted by bricker42
Two things:
I think
Code:
var parentNode = nodeList(0) ;
should be
Code:
var parentNode = nodeList[0];
but I'm not sure of that.


Tried that, but nothing happened.
Quote:
Also, "root" is undefined, so
Code:
root.appendChild(person_commentNode); 
is going to break. I think you meant parentNode instead of root. You should also move that line after the following 5, otherwise you won't get the result you're expecting.


Yes, you're right. I meant parentNode. I also moved that line after the other five appendChild statements, but still no result. The parentNode is still null. Thanks anyway!

Reply With Quote
  #4  
Old September 13th, 2003, 04:07 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Well, you can try nodeList.item(0).

Reply With Quote
  #5  
Old September 14th, 2003, 08:27 AM
hhibo hhibo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 8 hhibo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I found the mistake.
xmlDoc.async="false"; should of course be xmlDoc.async=false;

Thanks for the effort. I really appreciate it.

bente

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > writing to xml-file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT