ReadDictionary from URL

Coding Questions, IDE related or anything else

ReadDictionary from URL

Postby udo.killermann » Sat Apr 10, 2010 7:04 pm

The Language Reference says:
ReadDictionary

Function ReadDictionary(FilePathOrURL As String) As Dictionary

ReadDictionary(...) is an easy way to read in a previously stored dictionary from a file (XML files storing object values of dictionaries in a human-readable format). You may even read html webpages with this function.


But it works only for XML files in plist format (at least for me). What doesn't work is reading HTML pages as stated by the Reference. I have looked at the NSDicitionary reference which states one has to stay with the plist format and doesn't show support for HTML format.

Code: Select all
Dim myDic As Dicitionary
 
  ' although a URL can be given to initialize the values
  ' the referenced XML file needs to be in the format specified
  ' by Apple as property lists (plist)
  ' opening any other format results in a stack dump within
  ' ObjectiveBasic
  ' init dicitionary with keys and values of Info.plist
 
 ' local file in the user's home directory
  ' myDic = ReadDicitionary("file:///Users/HU/Desktop/hund/Contents/Info.plist")
 
  ' remote file on a web server
    myDic = ReadDicitionary("http://home.htp-tel.de/ukillermann/Info.plist")

  ' this fails
   ' myDic = plist("http://home.htp-tel.de/ukillermann/index.html")


Can someone shed a light on this?

Thanks
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: ReadDictionary from URL

Postby berndnoetscher » Wed May 19, 2010 8:12 pm

udo.killermann wrote:The Language Reference says:
ReadDictionary

Function ReadDictionary(FilePathOrURL As String) As Dictionary

ReadDictionary(...) is an easy way to read in a previously stored dictionary from a file (XML files storing object values of dictionaries in a human-readable format). You may even read html webpages with this function.


But it works only for XML files in plist format (at least for me). What doesn't work is reading HTML pages as stated by the Reference. I have looked at the NSDicitionary reference which states one has to stay with the plist format and doesn't show support for HTML format.

Code: Select all
Dim myDic As Dicitionary
 
  ' although a URL can be given to initialize the values
  ' the referenced XML file needs to be in the format specified
  ' by Apple as property lists (plist)
  ' opening any other format results in a stack dump within
  ' ObjectiveBasic
  ' init dicitionary with keys and values of Info.plist
 
 ' local file in the user's home directory
  ' myDic = ReadDicitionary("file:///Users/HU/Desktop/hund/Contents/Info.plist")
 
  ' remote file on a web server
    myDic = ReadDicitionary("http://home.htp-tel.de/ukillermann/Info.plist")

  ' this fails
   ' myDic = plist("http://home.htp-tel.de/ukillermann/index.html")


Can someone shed a light on this?

Thanks
Udo



ReadString() is the function, which may be used to read html files from web locations.
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am


Return to Objective-Basic (Xcode 3)

Who is online

Users browsing this forum: No registered users and 0 guests

cron