Indexing XML nodes

Maybe someone can point me in the direction of a tutorial that addresses my problem or give me some advice to get me pointed in the right driection about this.

So in essence, I’m trying to merge XML Guestbook and [URL=“http://www.kirupa.com/web/xml/examples/newseditor.htm”]XML News Editor

I’m using the XML Guestbook that I made a month back as my base and I want to create an admin side to it so I can edit the entries without directly editing the xml file. This is where the news editor comes in. It has the ability to do just that, but the way the functions are written while indexing the node that is being edited isn’t explained in the tutorial. I just want to understand how it works so I can adapt it to my needs. I’ve searched and searched for information on node indexing, and I can’t find a useful thing.

This is what I’m hung up on:

var news_index = 0;
UpdateIndexText = function(){
if (!news_index){
index_txt.text = “*”;
title_txt.htmlText = “[ New ]”;
body_txt.text = “”;
}else{
index_txt.text = news_index;
title_txt.htmlText = GetTitleText(news_xml, news_index-1);
body_txt.htmlText = GetBodyText(news_xml, news_index-1);
}
}

AND

GetTitleText = function(news_xml, entry_index){
var entries = news_xml.firstChild.childNodes;
var title_element = entries[entry_index].firstChild;
return title_element.firstChild.nodeValue;
}
GetBodyText = function(news_xml, entry_index){
var entries = news_xml.firstChild.childNodes;
var body_element = entries[entry_index].firstChild.nextSibling;
return body_element.firstChild.nodeValue;
}
GetEntry = function(news_xml, index){
var entries = news_xml.firstChild.childNodes;
return entries[index];
}
GetNewsCount = function(news_xml){
var entries = news_xml.firstChild.childNodes;
return entries.length;
}

I don’t want to add a new entry with it, just edit the previous entries. How can I adapt that for the script I’ve already got in place?

(I tried to piece together where the variable index states which node I’m editing and then variables oldDate and oldMessage and such point to the attribute or childnode of that node. I failed MISERABLY! )

var oldDate = “Old Date”;
var oldTitle = myXML.firstChild.attributes.MyTitle;
var oldMessage = “Old Message”;
editMessage.dateField.text = oldDate;
editMessage.titleField.text = oldTitle;
editMessage.messageField.text = oldMessage;
editMessage.indexField.text = index;

*editMessage.closeButton.onRelease = function(){ *
*this._parent._visible = false; *
*createButton._visible = true; *
*editButton._visible = true; *
*} *
*editMessage.sendButton.onRelease = function(){ *
*var myTitle = this._parent.titleField.text; *
*var myMessage = this._parent.messageField.text; *
*if (myTitle == “” && myMessage == “”){ *
*entry.removeNode(); *
*return (0); *
}
*else if (myTitle == “”){ *
*this._parent.errorField.text = “please fill out your title”; *
*Selection.setFocus(this._parent.titleField); *
*} *
*else if (myMessage == “”){ *
*this._parent.errorField.text = “please leave a message”; *
*Selection.setFocus(this._parent.messageField); *
*} *
*else { *
*myXML.firstChild.appendChild(myXML.createElement(“entry”)); *
*myXML.firstChild.lastChild.attributes.myTitle = myTitle; *
*myXML.firstChild.lastChild.attributes.myDate = myDate; *
*myXML.firstChild.lastChild.appendChild(myXML.createElement(“myText”)); *
*myXML.firstChild.lastChild.lastChild.appendChild(myXML.createTextNode(myMessage)); *
*myXML.sendAndLoad(“processXML.php”, receiverXML); *
*this._parent._visible = false; *
*createButton._visible = true; *
*editButton._visible = true; *
*} *
}