How To - get XML node name

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
palanolho
Posts: 122
Joined: Sat Apr 27, 2013 11:40 pm

How To - get XML node name

Post by palanolho » Mon Oct 28, 2013 10:28 pm

Greetings Everyone,

I'm having a little trouble with a script I'm doing that work with XML trees.

I'm trying to get all the nodes from the XML tree (in memory) and add them to a dataArray to put on a datagrid form.
I'm using a loop with the revXMLFirstChild(...) and revXMLNextSibling(...) to iterate through the nodes and get the data I need.

However, one of the attributes need to add to the array is the node name.

Using the revXMLFirstChild(...) and revXMLNextSibling(...) functions the result is something like this: "/tokens/single[1]"

so, the information I need to set is only the "single".
I tried to search around for some function or way to do it but had no luck with it.

Anyone has any idea on how can I do this?

Many thanks ins advance,
- Miguel

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How To - get XML node name

Post by Mark » Wed Oct 30, 2013 11:37 pm

Hi Miguel,

Do you mean that you want to get the node name from the string "/tokens/single[1]"?

Code: Select all

set the itemDel to slash
put last item of myXmlPath into myNode --> single[1]
set the itemDel to "["
put item 1 of myNode into myNode --> single
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

palanolho
Posts: 122
Joined: Sat Apr 27, 2013 11:40 pm

Re: How To - get XML node name

Post by palanolho » Thu Oct 31, 2013 10:22 am

Greetigns Mark
put last item of myXmlPath into myNode --> single[1]
this was very helpful!! thanks a lot :)

Many thanks
- Miguel

Post Reply