getUserData returning "undefined" with XML


#1

I saw some posts for getUserData returning “undefined” with JSON, but I’m loading from XML that I think follows the template provided. Can anyone see something I might have missed in the data?

<?xml version='1.0' encoding='UTF-8'?> <tree id='0'> <item id='Q2' text='Mang'> <item id='Group7' text='Meeting Areas'> <item id='Resource9' text='Conference Room'> <userdata name='Location'></userdata> <userdata name='GroupBackColor'></userdata> <userdata name='GroupTextColor'></userdata> <userdata name='ResourceBackColor'>#54e316</userdata> <userdata name='ResourceTextColor'>#000000</userdata> <userdata name='RestrictedAccess'>1</userdata> </item> <item id='Resource8' text='Test'> <userdata name='Location'></userdata> <userdata name='GroupBackColor'></userdata> <userdata name='GroupTextColor'></userdata> <userdata name='ResourceBackColor'></userdata> <userdata name='ResourceTextColor'></userdata> <userdata name='RestrictedAccess'>0</userdata> </item> <item id='Resource10' text='Training Room'> <userdata name='Location'></userdata> <userdata name='GroupBackColor'></userdata> <userdata name='GroupTextColor'></userdata> <userdata name='ResourceBackColor'></userdata> <userdata name='ResourceTextColor'></userdata> <userdata name='RestrictedAccess'>0</userdata> </item> </item> </item> <item id='Q7' text='Patt'> <item id='Group1' text='Meeting Areas'> <item id='Resource1' text='Conference Room'> <userdata name='Location'>1st floor offices, East end</userdata> <userdata name='GroupBackColor'></userdata> <userdata name='GroupTextColor'></userdata> <userdata name='ResourceBackColor'>#0c00f0</userdata> <userdata name='ResourceTextColor'>#ffffff</userdata> <userdata name='RestrictedAccess'>0</userdata> </item> <item id='Resource3' text='Engineering Conference Area'> <userdata name='Location'>2nd floor, West end</userdata> <userdata name='GroupBackColor'></userdata> <userdata name='GroupTextColor'></userdata> <userdata name='ResourceBackColor'></userdata> <userdata name='ResourceTextColor'></userdata> <userdata name='RestrictedAccess'>0</userdata> </item> <item id='Resource2' text='Launch Area'> <userdata name='Location'>2nd floor, East end</userdata> <userdata name='GroupBackColor'></userdata> <userdata name='GroupTextColor'></userdata> <userdata name='ResourceBackColor'></userdata> <userdata name='ResourceTextColor'></userdata> <userdata name='RestrictedAccess'>0</userdata> </item> </item> <item id='Group6' text='Test'> </item> <item id='Group8' text='Vehicles'> <item id='Resource11' text='Ford Escape'> <userdata name='Location'></userdata> <userdata name='GroupBackColor'>#199400</userdata> <userdata name='GroupTextColor'>#ffffff</userdata> <userdata name='ResourceBackColor'></userdata> <userdata name='ResourceTextColor'></userdata> <userdata name='RestrictedAccess'>1</userdata> </item> </item> </item> </tree>

I tried wrapping the userdata in CDATA tags, but that didn’t seem to help.

I’m using Standard version 4.4 if it makes a difference.

Thanks in advance!


#2

Hello
Use callback:

tree.load(xml, function(){ tree.getUserData(id, name) })


#3

I found my problem. Userdata works fine, I was just passing a bad node ID. I was passing a resource ID number, forgetting that the nodes were actually called “Resource” + resource ID number. (e.g., sending “11” instead of “Resource11”)

Now that I’m passing the correct node ID, it’s working correctly.

Thank you!


#4

You are welcome :slight_smile: