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: Emmanuel <email@hidden>
- Date: Mon, 7 Nov 2005 14:59:11 +0100
At 11:18 AM +0000 11/7/05, pete boardman wrote:
On 3 Nov 2005, at 20:08, Emmanuel wrote:
Such as XMLLib.osax, for instance.
Emmanuel, thanks for the great XML tutorial on your Satimage site. I
learnt a lot of useful stuff. I hadn't realised how complicated XML
could be... :-)
:-)
I also didn't know that XPath provided a kind of query language for
XML files until I saw it working with your examples. It's not easy
(like regular expressions) but it could provide a good alternative
to cracking open XML the hard way. For example, to find the machine
name from the system profile XML file (like Matt's example earlier
did), it appears that you can do stuff like this:
--
set the_doc to XMLOpen alias "Macintosh
HD:Users:pete:Desktop:system_profile.xml"
set the_root to XMLRoot the_doc -- uses XMLLIB osax
set i to (XMLGetText (XMLXPath the_root with
"//key[text()='machine_name' ]/following-sibling::string[1]"))
--
(contents of first <string> element following a <key> element called
'machine_name').
Note however that since in that particular case the xml is really a
plist you can use the Plist commands, which save from writing
complicated XPaths, and is much faster.
When you open a Plist, some hashing occurs so that looking up a key
is then incredibly fast.
I don't think you can use XPaths with the Apple-supplied XML
scripting commands, though.
I don't think either.
Emmanuel
_______________________________________________
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