XML attributes as dictionary


(Andreas Kiel) #1

While I can set an elements attributes using a dictionary I can’t find a way to do it the other way round.
someElem’s attributes will give me an array(list) like the example below

((NSArray) {(NSXMLNamedNode) font=“Arial”, (NSXMLNamedNode) fontSize=“53”, (NSXMLNamedNode) fontColor=“1 1 1 1”, (NSXMLNamedNode) bold=“0”, (NSXMLNamedNode) italic=“0”, (NSXMLNamedNode) alignment=“center”})

But where to go from there?


(Shane Stanley) #2

You could try something like this:

set theDict to current application's NSDictionary's dictionaryWithObjects:(theArray's valueForKey:"name") forKeys:(theArray's valueForKey:"objectValue")

(Andreas Kiel) #3

Many Thanks Shane,

That one didn’t work but the one below :-):

set theDict to current application's NSDictionary's dictionaryWithObjects:(theArray's valueForKey:"objectValue") forKeys:(theArray's valueForKey:"name")


(Shane Stanley) #4

If only I had a dollar for every time I put keys before values :roll_eyes: