# Parsing XML - Loading lastChild, but can't go through siblings

**URL:** <https://forum.kirupa.com/t/parsing-xml-loading-lastchild-but-cant-go-through-siblings/257951>\
**Category:** Uncategorized\
**Created:** [April 18, 2008, 7:30pm UTC](https://forum.kirupa.com/t/parsing-xml-loading-lastchild-but-cant-go-through-siblings/257951 "2008-04-18T19:30:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zohaibzw](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zohaibzw](https://forum.kirupa.com/u/zohaibzw)\
**Post date:** [April 18, 2008, 7:30pm UTC](https://forum.kirupa.com/t/parsing-xml-loading-lastchild-but-cant-go-through-siblings/257951/1 "2008-04-18T19:30:27Z")

</div>

So, I essentially want to make [http://www.spoono.com/flash/tutorials/tutorial.php?id=21](http://www.spoono.com/flash/tutorials/tutorial.php?id=21) bring up the lastChild instead of the first. I’ve tried to modify the original code to this:

```auto
contacts.load("contacts.xml");
contacts.onLoad = function(success) {
if (success) {
       name_txt = this.firstChild.lastChild.attributes.name;
       email_txt = this.firstChild.lastChild.attributes.email;
       web_txt = this.firstChild.lastChild.attributes.website;
       _root.total = this.firstChild.childNodes.length;
       _root.current = _root.entry + 1;
       entryNum_txt = _root.current+" of "+ _root.total;
}
};

```

From:

```auto
 contacts.load("contacts.xml");
contacts.onLoad = function(success) {
if (success) {
       name_txt = this.firstChild.childNodes[_root.entry].attributes.name;
       email_txt = this.firstChild.childNodes[_root.entry].attributes.email;
       web_txt = this.firstChild.childNodes[_root.entry].attributes.website;
       _root.total = this.firstChild.childNodes.length;
       _root.current = _root.entry + 1;
       entryNum_txt = _root.current+" of "+ _root.total;
}
};

```

But what happens is the buttons don’t work, so I can’t go through the siblings or anything. The reason I want to load the lastChild is because I’m going take Kirupa’s XML Guestbook and use that to write to the xml file that this one loads - that way I won’t have to go into the xml document itself and write in it. I’ve also tried to modify the xml guestbook to “insertBefore”, but for some reason it doesn’t work - and I think that loading the lastChild is a lot easier than messing with the guestbook as much. I’d appreciate any help! I know there’s a way - I’ve just been searching all over and trying different things, but I can’t find a solution. Maybe someone here will be able to help me! Thanks!
