xml quickie
- Started
- Last post
- 8 Responses
- versa
i am braindead...help appreciated
how can i get a number/integer representing how many childnodes are under the firstchild
so in logic, this:
myXml = new XML();
myXml.ignoreWhite = true;
myXML.onLoad = parseMe;
myXml.load("images.xml");totalImages = firstChild.childNodes.length
though length obviously doesn't work here..
should i use something like:var images = this.firstChild.childNodes;
for(i in images){
Number(i)
}or something like that...
told you i was braindead
- jkosoy0
really it depends how your xml is formatted.
its anyone's guess from here. can you post it up for us to see?
- quik0
XML + Flash = Teh gayness.
- Seph0
firstly you need to create an onload function for when the xml is loaded
myXml .onLoad = function(sucess) {
if (sucess) {
processfunc(myXml );
}then load the XML itself
myXml.load('images.xml');
then write the function called 'processfunc' (called when loaded) that will get the number that you need.
Im not exactly sure what you are after but perhaps something like this:
function processfunc(myXml) {
numofImages = myXml.firstChild.childNodes.leng...
}
Well its definately something like that anyroad...
- versa0
i guess i didn't phrase that very well last night....
i understand how to parse for the most part, but am wondering how to get a specific number/integer representing the number of childNodes under the rootNode
something like this would make sense, but isn't apparently applicable to a childNodes array
totalImages = myXml.firstChild.chi ldNodes.length
thanks
- zack270
versa,
//make an array first:
totalImages = new Array();
//then:
totalImages = myXml.firstChild.childNodes;
// then just do
totalImages.length;
- zack270
ps- you gotta do that because .childNodes returns an array of the names of the childnodes in your xml document...
- versa0
i gave that approach a try and am tracing the value of totalImages, and am still getting nothing
any ideas ?
- versa0
oh, ok, i got it working
thanks guys