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

XML DOM issue: cannot clone nodes to xml file

Status
Not open for further replies.

n0rb3r7

Programmer
Dec 4, 2008
2
US
I am having an issue with the XML Dom
I am trying to create a simple system where a user inputs a comment which is then written to the xml file using the XML Dom. I'm not sure what my problem is, so I'll post all relevant information, thanks in advance.

XML FILE:

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href=" ?>


<article_space>

<com>
<user>Seth_Bean</user>
<c_date>Today</c_date>
<c_body>Rad post brah</c_body>
</com>

<article>

<title>article1</title>
<author>Barbara</author>
<date>Today</date>

<body_text>
This is my article, hello.
</body_text>
</article>

</article_space>

Javascript function:

function addComment(form)
{
var param = '<xsl:value-of select="/article_space/article/title" />'; xmlDoc = loadXMLDoc(""+param+".xml");

<!--param is used for the title of the file to be opened-->
xmlDoc=loadXMLDoc(param+".xml");

<!--Clones the comment node and it's children-->
var root = xmlDoc.documentElement;
var curr_node = root.firstChild;
var new_node = curr_node.cloneNode(true);
root.appendChild(new_node);

<!--values from a form-->
var text = form.text.value;
var id = form.id.value;

<!--Adds text to the comment node-->
x=xmlDoc.getElementsByTagName("c_body")[0].childNodes[0];
x.nodeValue= text;

x=xmlDoc.getElementsByTagName("user")[0].childNodes[0];
x.nodeValue = id;

return true;
}

the input form:

<div id="c_input" name="c_input">
<form onsubmit="addComment(this.form)" id="input_comment" method="post">
<input id="id" type="text" />
<textarea id="text" cols="30" rows="10"/><br />
<input type="submit" value="Post Comment" />
</form>
</div>
 
>var param = '<xsl:value-of select="/article_space/article/title" />';
What possibly can it be in the user agent executing the javascript?
 
This stylesheet is being used by multiple xml documents, this is a standard system to print out various article files.
 
>This stylesheet is being used by multiple xml documents, this is a standard system to print out various article files.
So? Does it make thing clearer? If that is private "standard", maybe you should rather answer your colleague for help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top