Subject: | |
From: | |
Reply To: | |
Date: | Tue, 29 May 2007 23:33:46 +0200 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Assuming that what you're trying to do is to get all the "Titles"
from your XML document, here is an equivalent using XMLLib :
set theXML to XMLOpen (choose file)
XMLGetText (XMLXPath (XMLRoot theXML) with "//title")
XMLClose theXML
-> {"Art/Soul/Africa: A Photographer's Journey", "Campus Tour", "In
the Founders' Footsteps: Builders of the Cornell University Library"}
On May 29, 2007, at 10:55 PM, Bill Steele wrote:
>> CAn you send us a XML sample and your script ? I'm using the
>> XMLLib scripting a lot and in my experience parsing XML documents
>> has never required much call to the osax.
>>
>> ++ JB
>>
>> On May 29, 2007, at 5:10 PM, Bill Steele wrote:
>>
>>> Whatever it is, it sure isn't intuitive. Most everything I've
>>> tried brings back "Can't make .... into type reference" or just
>>> "can't get every..."
>>>
>>> Satimage XML suite works, but seems to require an awful lot of
>>> steps to get down to the data.
>>> --
>>>
>>> Bill Steele
>>> [log in to unmask]
>
>
> Here are some things that don't work:
>
> set foo to choose file
>
> tell application "System Events"
>
> set bar to XML data of foo
> set Fred to XML elements of bar
>
> set bar to XML data of XML file foo
> set Fred to XML elements of bar
>
> set theEntries to XML elements of XML data of XML file foo
>
> set George to value of XML element "title" of XML data of XML file foo
>
> end tell
>
> (I find it curious that the dictionary says XML data is contained
> by *application," not file. )
>
> All this is in Tiger 10.4.9
>
> a short piece of a very long file.
>
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <eventlist>
> <event>
> <eventid>16065</eventid>
> <title>Art/Soul/Africa: A Photographer's Journey</title>
>
> <category>Exhibit</category>
> <location>Museum of the Earth</location>
> <room></room>
> <date>2006-09-07</date>
> <time>All Day</time>
> <duration></duration>
> <recurring>yes</recurring>
>
> <cancelled>no</cancelled>
> <keywords></keywords>
> </event>
> <event>
> <eventid>15627</eventid>
> <title>Campus Tour</title>
> <category>Tour</category>
>
> <location>Day Hall</location>
> <room>Lobby</room>
> <date>2006-09-07</date>
> <time>09:00:00</time>
> <duration>01:15:00</duration>
> <recurring>yes</recurring>
>
> <cancelled>no</cancelled>
> <keywords></keywords>
> </event>
> <event>
> <eventid>16466</eventid>
> <title>In the Founders' Footsteps: Builders of the Cornell
> University Library</title>
> <category>Exhibit</category>
>
> <location>Kroch Library</location>
> <room>Hirshland Gallery</room>
> <date>2006-09-07</date>
> <time>09:00:00</time>
> <duration>08:00:00</duration>
> <recurring>yes</recurring>
>
> <cancelled>no</cancelled>
> <keywords></keywords>
> </event>
> </eventlist>
>
>
>
>
> --
>
> Bill Steele
> [log in to unmask]
|
|
|