# Trying to display an xml attribute

**URL:** <https://forum.kirupa.com/t/trying-to-display-an-xml-attribute/29887>\
**Category:** Uncategorized\
**Created:** [September 1, 2003, 3:50pm UTC](https://forum.kirupa.com/t/trying-to-display-an-xml-attribute/29887 "2003-09-01T15:50:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![j0se](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/j0se/32/44_2.png) [@j0se](https://forum.kirupa.com/u/j0se)\
**Post date:** [September 1, 2003, 3:50pm UTC](https://forum.kirupa.com/t/trying-to-display-an-xml-attribute/29887/1 "2003-09-01T15:50:01Z")

</div>

Hi chaps and chapesses,

I’m trying to display an XML attribute, but I’m having no luck - can anyone help me navigate the object properly?

this is the simple xml file (which i found it in one of Senocular’s examples):

‘\<‘LETTER’\>’  
‘\<‘TO’\>‘Sandy’\</‘TO’\>’  
‘\<‘FROM’\>‘Joseph’\<’/FROM’\>’  
‘\<‘BODY’\>‘I love you!’\<’/BODY’\>’  
‘\<’/LETTER’\>’

this is my as:

```php

// create XML object
var xmlDoc = new XML();

xmlDoc.onLoad = parseXML;

// load the xml doc
xmlDoc.load("test.xml");

function parseXML( success )
{
        if( success )
        {
                // outputs all the tags
                trace( this.firstChild );
	
                 // outputs the tag: LETTER
                trace( this.firstChild.nodeName);
	
                // outputs the tag: TO 
               trace( this.firstChild.firstChild.nodeName );
	
                // outputs the tag: TO & its value
                trace( this.firstChild.firstChild );	
		        
        }else{
        	
                  trace("error");
        }
}

```

that’s as far as I’ve got

I’m tryig to figure out how to output the rest of the tags - (FROM & BODY)

are they stored in an object following the firstChild.firstChild?

cheers

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 1, 2003, 5:40pm UTC](https://forum.kirupa.com/t/trying-to-display-an-xml-attribute/29887/2 "2003-09-01T17:40:53Z")

</div>

\<_LETTER\>  
\<TO\>Sandy\</TO\>  
\<FROM\>Joseph\</FROM\>  
\<BODY\>I love you!\</BODY\>  
\<_/LETTER\>

forgot the end tags for the TO and FROM 😉

take out the "\*"s too. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 1, 2003, 6:28pm UTC](https://forum.kirupa.com/t/trying-to-display-an-xml-attribute/29887/3 "2003-09-01T18:28:45Z")

</div>

cheers froZenX,

but the html is fine (the tags are a little messed up in my post because I was trying to isolate them using ‘’, as i didn’t know you could use \*)

anyway, assume the xml file is fine

what I’m trying to get right is the as

cheers  
🙂
