• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to work with XML data using System Events?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to work with XML data using System Events?


  • Subject: Re: How to work with XML data using System Events?
  • From: Matt Neuburg <email@hidden>
  • Date: Fri, 11 Nov 2005 16:47:30 -0800
  • Thread-topic: How to work with XML data using System Events?

On Fri, 4 Nov 2005 17:55:27 +0000, has <email@hidden> said:
>Matt Neuburg wrote:
>
>> >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

>But anyway, when working with plists it's simpler to use SE's dedicated PList
Suite

I know. That's why I used that example; the Plist version is on the next
page. :) m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>



 _______________________________________________
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

  • Prev by Date: Re: Styled text to html
  • Next by Date: Re: How to work with XML data using System Events?
  • Previous by thread: Re: How to work with XML data using System Events?
  • Next by thread: Re: How to work with XML data using System Events?
  • Index(es):
    • Date
    • Thread