I am trying to find which of the following "object" nodes contains a url within the linkurl attribute. The linkurl attribute will always be there even if there is no content within the attribute. I'm not having any luck because I can;t find a way to determine if the first instance of the linkurl in the first object node is empty, and move on to the second and then third etc. The attribute always contains something even if there is no content in the attribute itself.
This is the xml
<object id='graphic1' active='1' url='media/00360691.swf' x='445' y='125' alt='' altfr='' altes='' tabIndex='1' layer='0' linkurl=''/>
<object id='graphic2' active='0' url='media/00360691.swf' x='0' y='0' alt='' altfr='' altes='' tabIndex='1' layer='0' linkurl='html/AnalyticalReviewAnalysis.pdf'/>
<object id='graphic3' active='0' url='media/00360692.swf' x='0' y='0' alt='' altfr='' altes='' tabIndex='1' layer='0' linkurl=''/>
<object id='graphic4' active='0' url='media/00360693.swf' x='0' y='0' alt='' altfr='' altes='' tabIndex='1' layer='0' linkurl=''/>
<object id='graphic5' active='0' url='media/' x='0' y='0' alt='' altfr='' altes='' tabIndex='1' layer='0' linkurl=''/>
<object id='activity' active='0' url='media/' x='0' y='0'/>
This is what I have tried so far:
if(myXML.object[7].hasOwnProperty("@linkurl")){
trace("graphic 1 is not empty");
linkURL = myXML.object[7].attribute("linkurl")[0];
} else {
trace("graphic 1 is empty");
}
trace("length: "+myXML.object[7].attribute("linkurl")[0].length());
trace(myXML.object[7].attribute("linkurl")[0]);
trace("linkURL: "+ linkURL);
This is what traces:
graphic 1 is not empty
length: 1
linkURL:
The length is always 1 regardless of whether the attribute contains content or does not. Thus, I have no way to disregard the empty node, and move on to the next one. The if statement always comes up not empty, because even if linkurl="", it still has something.