Link to home
Start Free TrialLog in
Avatar of paulp75
paulp75Flag for Australia

asked on

preventing blank xml records outputting as undefined

in my xml file i have a part of it that goes like this

<store>
<name>Harvey Norman Outlets</name>
<address></address>
<suburb></suburb>
<postcode></postcode>
<phone></phone>
</store>

which when it is output through flash it outputs as
Harvey Norman Outlets
undefined
undefined
undefined
undefined

in the dynamic text. thanks to aneeshchopra ive got all the stores to output now, but now i'm just left with this one problem there.

this is the code in the flash file.

function loadXML(loaded) {

if (loaded) {
dB = new Array();
for(var i =0; i < xmlData.firstChild.childNodes.length; i ++){
// this.firstChild.childNodes[] refers to which store record you refer to
// this.firstChild.childNodes[].ChildNodes[0] refers to the store name
// this.firstChild.childNodes[].ChildNodes[1] refers to the store address
// this.firstChild.childNodes[].ChildNodes[2] refers to the store suburb
// this.firstChild.childNodes[].ChildNodes[3] refers to the store phone

_root.presentation.Retailers.waslide.waholder.text += this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue +  newline + this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue + newline + this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue + newline + this.firstChild.childNodes[i].childNodes[3].firstChild.nodeValue + newline + newline;
}
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("wa.xml");

thanks
Avatar of trigger-happy
trigger-happy
Flag of Philippines image

Try to add a little if statement in there that will check if the value of that certain node is undefined. If so then change the value to something else like an empty space " " so that you won't see the undefined message.

--trigger-happy
ASKER CERTIFIED SOLUTION
Avatar of CyanBlue
CyanBlue
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial