Need a reference for a simple real-time or same-day close fund prices

(Shane Stanley) #21

Like this:

tell application id "" -- Safari
	set theSource to source of document 1
end tell
set {theXMLDoc, theError} to current application's NSXMLDocument's alloc()'s initWithXMLString:theSource options:(current application's NSXMLDocumentTidyHTML) |error|:(reference)
if theXMLDoc = missing value then error (theError's localizedDescription() as text)

(Stan Cleveland) #22

Hi Shane,

I tried your code on a mid-size web page ( and found that the returned XMLDoc is cut short and has this message appended to the end:

<<description truncated at 2000 characters out of 10635>>

Is the XMLDoc actually being truncated or is the result clipped only for display purposes? If the truncation is actually happening, can it be disabled?

Stan C.

(Shane Stanley) #23

It’s for display (and performance) purposes. You can change the amount of truncation using the expert preference key PrefDescriptionOtherLimit, which defaults to 2000. I’ve updated the entry here to cover it:

A bug in earlier Script Debugger 6 versions meant the setting did nothing, but it should work as described in both the latest release of 6 as well as 7.

But everything is actually still there!

(Shane Stanley) #24

Just to add to this…

Script Debugger uses various methods to display Cocoa objects. In many cases what you see is the result of calling the debugDescription method on the object. Depending on the class, the result of this can vary from very terse to quite detailed. In some common cases we clean it up quite a bit, to make it appear more AppleScript-like. In the case of NSXMLDocument, it is the full text of XML.

If you want to see the full description raw, you can also call the method yourself. For example:

log (theXMLDoc's |description|() as text)

For occasional use, this is probably preferable than setting the default to large number. But some descriptions are very long.

(Stan Cleveland) #25

Hi Shane,

Got it. That confirms my suspicion. Many thanks for your helpful insights.

Stan C.