By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

Not an object? Well, it is too!

mrmiffo
P: 8
Hi all!
I have probably a simple problem but, as for all problems it is huge for me since I'm the one having it... I'm trying to work my way up to the mother of mothers in an XML file starting with a clicked node and what goes wrong is that even when I get the parents' label - the parent is not acknowledged as an object...

This I have in a loop:
Expand|Select|Wrap|Line Numbers
  1. myLabel = currentNode.parentNode.getAttribute('label');
  2. currentNode  = clone(currentNode.parentNode);  
(as you can see I want to climb up parent by parent and get their labels)

myLabel returns the right label the first round of the loop and that's just all swell, it tells me that currentNode.parrentNode actually is an object, otherwise it would not return the attribute 'label' would it?
BUT: the second line will not pass the first round of the loop so there will be no second round of the loop - currentNode.parentNode is null or not an object it says...

I have most likely missed fundamental stuff since I'm learning this stuff along with the various projects I'm involved in.


Please advice - I'm lost.

Thanks.
Nov 5 '07 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Can you give some more code, e.g. how you define currentNode, the clone function.
Nov 5 '07 #2

mrmiffo
P: 8
Can you give some more code, e.g. how you define currentNode, the clone function.
Thanks, I feel rather stupid now when I have figured out what I did wrong... it was a very dumb attempt to check if the object in fact was an object... more stupid was that I did not post all the code in the first place - then you had seen the bad code directly...

it was:
Expand|Select|Wrap|Line Numbers
  1. if("" + currentNode == "")
which was my lame attempt to check if currentNode was something at all...
Now I use:
Expand|Select|Wrap|Line Numbers
  1. if(typeof(currentNode) != 'object')
and it works like a charm...

Really sorry for taking your time!

Thanks.
Nov 5 '07 #3

acoder
Expert Mod 15k+
P: 16,027
It's no problem. At least your problem's resolved which is what we like to see!
Nov 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.