xml osax

GO TO ADMIN PANEL > ADD-ONS AND INSTALL VERTIFORO SIDEBAR TO SEE FORUMS AND SIDEBAR

deeg

New member
Joined
Jul 1, 2003
Messages
394
Points
0
Location
Swampland, UK
hi all,

info for any writers .. Smile have released an XML extension for Applescript.. details http://www.satimage.fr/software/en/xml_suite.html.

If you are not sure, Smile is an alternative environment for writing Applescripts, it has extend dialog capabilities compared to the normal editor amongst other things.

Referencing the XML file of the itunes library is often quicker than asking iTunes directly.

hth

Deeg
 

WoodenBrain

New member
Joined
Jun 8, 2005
Messages
245
Points
0
Website
beam.to
deeg,

do you have an example of how to use this OSAX with the iTunes xml file? I can't get past xmlopen. I get an "access not allowed" on the xmlOpen line when trying to compile.

set itxml to "~/Music/iTunes/iTunes Music Library.xml"
tell me to set itxmlhfs to POSIX file (itxml as string)
set xmlref to XMLOpen itxml
XMLClose

what I'm ultimately trying to do is get the "release date" of a podcast, but I just noticed that it's not in the XML either. it's not accessable via applescript, it's not in the xml, it's not in spotlight, and it's not in the finder comments! where could that info be kept?

edit: i found the release date.... but still don't know how to access it. it's in the hex.

please use this thread just for the xml question, i'll put the question about the podcast release date in the podcast thread i already started.
 
Last edited:

deeg

New member
Joined
Jul 1, 2003
Messages
394
Points
0
Location
Swampland, UK
hi,

not used it myself, i was just sharing the mail...

there is some doc if you have not seen this..

notice you are getting a posix path to the xml file but dont appear to use the posix path in the XMLopen..

will load up the xml extension and have a play but am on shifts currently so it'll be a few days..

there is an xml suite in applescript itself now, its in the dictionary somewhere but am away from my Macs currently so cannto give you the exact location..
 

WoodenBrain

New member
Joined
Jun 8, 2005
Messages
245
Points
0
Website
beam.to
notice you are getting a posix path to the xml file but dont appear to use the posix path in the XMLopen..

will load up the xml extension and have a play but am on shifts currently so it'll be a few days..
yeah, sorry, i tried both.

and whenever--it turns out this won't help get that release date I'm trying to extract anyway. just curious for future reference.
 

deeg

New member
Joined
Jul 1, 2003
Messages
394
Points
0
Location
Swampland, UK
the code they have on their site appears to work for me,

set thedoc to choose file
set the_doc to XMLOpen thedoc
set the_root to XMLRoot the_doc
XMLCount the_root
set the_child to XMLChild the_root index 1
XMLDisplay the_child
set the_child_2 to XMLChild the_child index 1
XMLDisplay the_child_2
XMLGetText the_child_2
set the_child_2 to XMLNextSibling the_child_2
XMLDisplay the_child_2
XMLGetText the_child_2

gives...

tell current application
choose file
alias "Stan:Users:paul:Music:iTunes:iTunes Music Library.xml"
XMLOpen alias "Stan:Users:paul:Music:iTunes:iTunes Music Library.xml"
«data XMLR0000000400000000»
XMLRoot «data XMLR0000000400000000»
«data XMLR0000000406228C90»
XMLCount «data XMLR0000000406228C90»
1
XMLChild «data XMLR0000000406228C90» index 1
«data XMLR0000000406228D10»
XMLDisplay «data XMLR0000000406228D10»
{kind:"ELEMENT_NODE", name:"dict"}
XMLChild «data XMLR0000000406228D10» index 1
«data XMLR00000004003C3220»
XMLDisplay «data XMLR00000004003C3220»
{kind:"ELEMENT_NODE", name:"key"}
XMLGetText «data XMLR00000004003C3220»
"Major Version"
XMLNextSibling «data XMLR00000004003C3220»
«data XMLR00000004003C32A0»
XMLDisplay «data XMLR00000004003C32A0»
{kind:"ELEMENT_NODE", name:"integer"}
XMLGetText «data XMLR00000004003C32A0»
"1"
end tell
 

WoodenBrain

New member
Joined
Jun 8, 2005
Messages
245
Points
0
Website
beam.to
code snippet or library for accessing iTunes xml?

just wondering if anyone has come up with a simple and fast way to access a particular track record in the xml, or any related libraries. rather than reinvent the wheel.

I'm still not optimistic. Using system events' xml suite, this simple statement:

Code:
tell application "System Events" to set tf to XML file (music_hfs)
... times out after 2 minutes (when run from script editor). It seems that must load the entire file into memory, which is a big job with an xml file that's nearly 200 MB.

I need a fast way to get a particular key from a particular record (by ID or some other way).
 

WoodenBrain

New member
Joined
Jun 8, 2005
Messages
245
Points
0
Website
beam.to
S2_Mac said:
What happens if you call Perl to extract a record from the xml file? (I'd test, but don't have a 200MB xml file layin' around ;-)
Hmm... I don't have enough proficiency in Perl to write such a call. If you were willing to provide some code that would pull up the record given a persistent ID (or another method?) of a track, I would test it gladly only my file! Thanks.
 
Top