Page 1 of 1

ReadDictionary from URL

PostPosted: Sat Apr 10, 2010 7:04 pm
by udo.killermann
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

Re: ReadDictionary from URL

PostPosted: Wed May 19, 2010 8:12 pm
by berndnoetscher
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.