Thursday, September 20, 2018

#1 2018-06-24 07:06:55 am

technomorph
Member
Registered: 2017-12-14
Posts: 46

Getting list of the Element Names from NSXMLElement Array

I have a list called theNodesENTRYFULL (see attached pic)
I would like to repeat through the list with each entry
and get a list of all of the NSXMLElement Names.
eg
ITEM1:
{"ENTRY", "LOCATION", "ALBUM", "MODIFICATION_INFO", "INFO", "TEMPO"}
ITEM2:
{"ENTRY", "LOCATION", "ALBUM", "MODIFICATION_INFO", "INFO", "TEMPO", "LOUDNESS", "MUSICAL_KEY", "CUE_V2"}
etc

Pic of the List

thanks

Last edited by technomorph (2018-06-24 07:09:59 am)


Filed under: xml, xpath, objc, NSXMLElement

Offline

 

#2 2018-06-24 07:20:05 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5448

Re: Getting list of the Element Names from NSXMLElement Array

First, you want arrays rather than lists. Then something like:

Applescript:

set theList to {}
repeat with anArray in theNodesENTRYFULL
set end of theList to (anArray's valueForKey:"name") -- add "as list" if you want a list
end repeat


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2018-06-24 07:38:08 am

technomorph
Member
Registered: 2017-12-14
Posts: 46

Re: Getting list of the Element Names from NSXMLElement Array

Shane Stanley wrote:

First, you want arrays rather than lists. Then something like:

Applescript:

set theList to {}
repeat with anArray in theNodesENTRYFULL
set end of theList to (anArray's valueForKey:"name") -- add "as list" if you want a list
end repeat



Oh man it's just like how I get the attribute names and values like

Applescript:

set propNames to theResults's valueForKeyPath:"attributes.name"
set propValues to theResults's valueForKeyPath:"attributes.stringValue"

Thanks again so much!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)