# Change xml news\_editor to read attributes

**URL:** <https://forum.kirupa.com/t/change-xml-news-editor-to-read-attributes/125215>\
**Category:** Uncategorized\
**Created:** [October 11, 2004, 6:42pm UTC](https://forum.kirupa.com/t/change-xml-news-editor-to-read-attributes/125215 "2004-10-11T18:42:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gf05856](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gf05856](https://forum.kirupa.com/u/gf05856)\
**Post date:** [October 11, 2004, 6:42pm UTC](https://forum.kirupa.com/t/change-xml-news-editor-to-read-attributes/125215/1 "2004-10-11T18:42:43Z")

</div>

Dear,

I would like to use the xml news\_editor to read on attributes rather than on siblings… for editing a xml file looking like:

[color=#0000ff]\<?xml version=“1.0” encoding=“utf-8” ?\>[/color]  
[**[font=Courier New][color=#ff0000]-[/color][/font]**](file:///C:/Documents%20and%20Settings/Frederik%20De%20Fruyt/My%20Documents/Events.xml#) [color=#0000ff]\<[/color][color=#990000]Events[/color][color=#0000ff]\>[/color]  
**[font=Courier New][color=#ff0000] [/color][/font]** [color=#0000ff]\<[/color][color=#990000]Event[/color] [color=#990000]DateOf[/color][color=#0000ff]="[/color] **01/04/2004** [color=#0000ff]"[/color][color=#990000] Hour[/color][color=#0000ff]="[/color] **10:20** [color=#0000ff]"[/color][color=#990000] Header[/color][color=#0000ff]="[/color] **FREDERIK** [color=#0000ff]"[/color][color=#990000] Content[/color][color=#0000ff]=“Event 1[/color][color=#0000ff]”[/color][color=#990000] AddedOn[/color][color=#0000ff]="[/color][color=#000000] **Sat Oct 9 14:33:58 GMT+0200 2004** [/color][color=#0000ff]" /\>[/color]

**[font=Courier New][color=#ff0000] [/color][/font]** [color=#0000ff]\<[/color][color=#990000]Event[/color] [color=#990000]DateOf[/color][color=#0000ff]="[/color] **01/05/2004** [color=#0000ff]"[/color][color=#990000] Hour[/color][color=#0000ff]="[/color] **11:30** [color=#0000ff]"[/color][color=#990000] Header[/color][color=#0000ff]="[/color] **ILSE** [color=#0000ff]"[/color][color=#990000] Content[/color][color=#0000ff]=“Event 2[/color][color=#0000ff]”[/color][color=#990000] AddedOn[/color][color=#0000ff]="[/color] **Sat Oct 9 14:33:58 GMT+0200 2004** [color=#0000ff]" /\>[/color]

**[font=Courier New][color=#ff0000] [/color][/font]** [color=#0000ff]\</[/color][color=#990000]Events[/color][color=#0000ff]\>[/color]  
[color=#0000ff][/color]

I managed to change already a lot, so I can add new items to the list. Only the EDITING OF EXISTING ITEMS DOES NOT SEEM TO WORK to work.

Can somebody help me on this (below the edit code):

EditNewsEntry = function(news\_xml, node\_index, title, body, dates, hour){  
var entry = GetEntry(news\_xml, node\_index);  
if (title == “” && body == “”){  
entry.removeNode();  
return (0);  
}else{  
if (title == “”) title = “(none)”;  
if (body == “”) body = “(none)”;  
}  
entry.attributes.AddedOn = new Date().toString();  
var titleTextNode = entry.attributes.Header;  
var bodyTextNode = entry.attributes.Content;  
trace (titleTextNode);  
bodyTextNode.nodeValue = body;

[//entry.attributes.DateOf](https://entry.attributes.DateOf) = dates;  
[//entry.attributes.Hour](https://entry.attributes.Hour) = hour;  
[//entry.attributes.Header](https://entry.attributes.Header) = title;  
[//entry.attributes.Content](https://entry.attributes.Content) = body;  
}

AND ALSO THE BODYTEXT CODE

GetBodyText = function(news\_xml, entry\_index){  
var entries = news\_xml.firstChild.childNodes;  
var body\_element = entries[entry\_index].firstChild;  
return body\_element.firstChild.nodeValue;  
}

I will use this to add events to a calendar, should also be password protected in the future.  
Thanks for your help…  
I am already struggling some day’s on this…  
Frederik.  
Visit: [http://www.baby.shyper.com/Flash/Other/EventsCalendar.swf to see the calendar. Or visit to see the work I have managed so far [url=“http://www.baby.shyper.com/Flash/Other/EventsCalendar.swf”]http://www.baby.shyper.com/Flash](http://www.baby.shyper.com/Flash/Other/EventsCalendar.swf)
