Re: How to work with XML data using System Events?
Re: How to work with XML data using System Events?
- Subject: Re: How to work with XML data using System Events?
- From: Emile Schwarz <email@hidden>
- Date: Sat, 05 Nov 2005 09:38:10 +0100
Hi,
you need to add a test on the running AppleScript (or Mac OS X) version because
if you run it on Mac OS X 10.3.9 you will get:
Syntax error found
waiting "," but found "text"
on line: "set s to (XML text of document 1)"
Sorry,
Emile
email@hidden wrote:
> Date: Fri, 04 Nov 2005 05:47:56 -0800
> From: Matt Neuburg <email@hidden>
> Subject: Re: How to work with XML data using System Events?
> To: pete boardman <email@hidden>
> Cc: email@hidden
> Message-ID: <BF90A68C.FF34%email@hidden>
> Content-Type: text/plain; charset="ISO-8859-1"
>
> On Tue, 1 Nov 2005 17:17:52 +0000, pete boardman <email@hidden>
> said:
>
>>> The System Events dictionary contains these commands:
>>>
>>> XML attribute
>>> XML data
>>> XML element
>>> XML file
>>>
>>> How would I use these to read XML data from an XML file?
>
>
>
> Example (from you-know-where):
>
> tell application "System Profiler"
> set s to (XML text of document 1)
> end tell
> on findElementWithValue(e, v)
> tell application "System Events"
> repeat with i from 1 to (count XML elements of e)
> if value of XML element i of e is v then
> return i
> end if
> end repeat
> end tell
> error "not found"
> end findElementWithValue
> tell application "System Events"
> set x to make new XML data with data s
> set e to XML element 1 of XML element 1 of x
> set e to first XML element of e where ¬
> value of XML element 2 of it is "SPHardwareDataType"
> set i to my findElementWithValue(e, "_items")
> set e to XML element 1 of XML element (i + 1) of e
> set i to my findElementWithValue(e, "machine_name")
> return value of XML element (i + 1) of e -- iMacG5
> end tell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden