• 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: xml text to record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xml text to record


  • Subject: Re: xml text to record
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 22 Nov 2011 09:50:32 +0100

Le 21 nov. 2011 à 18:48, Luther Fuller a écrit :

> [...]
>
> If I log the raw text, I can see the difference in the response, but I can't see how to make a record form the xml text. 'system_profiler' must be an exception. Or there's something more I need to understand.
>
> Anyone see what my problem is?

Hello Luther,

A plist is a special case of XML data; a very narrow case, in fact.
With the -xml option, drutil returns text organized as XML, structured as an "infodoc".
When run with the -xml option, system_profiler returns XML data as well, structured as a "plist".

The Property List Suite of System Events is specialized in the handling of XML data organized as a plist; that specialization heavily relies upon the one-to-one relationship between plists and AppleScript records. As a result, the Property List Suite can't be fed with XML data other than a plist, since the various expected items (dicts, arrays, strings...) won't be encountered at all, or won't be structured in the expected way (can't be univocally represented as an AppleScript record).

To handle XML data in the general case (even a plist) with System Events, one needs to resort to its XML Suite. Of course, due to the lack of specialization, this proves slightly less convenient.

In the case of drutil, you could thus try with:

	set response to do shell script "drutil info -xml"
	tell application "System Events"
		set infoRecord to (make XML data with properties {text:response})
	end tell

HTH,
Axel

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: xml text to record
      • From: Axel Luttgens <email@hidden>
References: 
 >xml text to record (From: Luther Fuller <email@hidden>)

  • Prev by Date: Smart Mailboxes
  • Next by Date: Re: xml text to record
  • Previous by thread: xml text to record
  • Next by thread: Re: xml text to record
  • Index(es):
    • Date
    • Thread