• 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: Call getElementById in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Call getElementById in Cocoa


  • Subject: Re: Call getElementById in Cocoa
  • From: Pierce Freeman <email@hidden>
  • Date: Mon, 24 Nov 2008 17:10:48 -0800
  • Thread-topic: Call getElementById in Cocoa

Okay, sounds good.  Just making sure, would that code would work?


Sincerely,

Pierce F


On 11/24/08 3:54 PM, "Jean-Daniel Dupas" <email@hidden> wrote:

> The link I provided is for another option, using Javascript call to
> retreive the value, but I think using the native DOM API is prefered.
>
> Note that before calling mainFrameDocument, you should make sure the
> document is loaded. There is probably a WebView delegate method that
> provide this info.
>
>
> Le 25 nov. 08 à 00:43, Pierce Freeman a écrit :
>
>> Does this code convey what you are saying/how to do this?
>>
>> IBOutlet id webView;
>>
>> NSString *urlOfObject = [NSString stringWithFormat:
>> @"http://www.somesite.com/hiddenFieldPage.php";];
>>
>>
>> [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL
>> URLWithString:urlOfObject]]];
>>
>> DomDocument *domObject = [webView mainFrameDocument];
>>
>> NSString *hiddenField = [domObject getElementById:@"hiddenField"];
>>
>> Also, how would the link that you gave come into play in this case?
>>
>>
>> Sincerely,
>>
>> Pierce F
>>
>>
>>
>> On 11/24/08 8:11 AM, "Jean-Daniel Dupas" <email@hidden>
>> wrote:
>>
>>>
>>> Le 24 nov. 08 à 16:42, Pierce Freeman a écrit :
>>>
>>>> Hi everyone.
>>>>
>>>> I am wondering if there is some way to call the getElementById on a
>>>> website
>>>> through Cocoa, and then return the value of the field.  I am
>>>> assuming it
>>>> would somehow be through WebKit, but I am not sure how to do this
>>>> (as well
>>>> as if the method needs a different way to get the page's code).  The
>>>> use
>>>> would be the application getting the value of a hidden field, and
>>>> then
>>>> outputting it to the user.
>>>>
>>>>
>>>> Sincerely,
>>>>
>>>> Pierce Freeman
>>>
>>> You can do this either by using the Cocoa DOM API directly:
>>>
>>> You call -mainFrameDocument on your WebView to get a DOMDocument
>>> instance, and have access to the DOM functions from here (there is no
>>> up-to-date doc of the Cocoa DOM API, you will have to check headers
>>> files directly to see what function is available, for example the
>>> DOMDocument.h file show you that there is a -[DomDocument
>>> getElementById:] method.
>>>
>>> or you can execute js from your Cocoa code:
>>>
>>> http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/
>>> Ta
>>> sks/JavaScriptFromObjC.html
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Call getElementById in Cocoa
      • From: "Adam R. Maxwell" <email@hidden>
References: 
 >Re: Call getElementById in Cocoa (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Need some advice on multithreading
  • Next by Date: Re: MVC in Cocoa?
  • Previous by thread: Re: Call getElementById in Cocoa
  • Next by thread: Re: Call getElementById in Cocoa
  • Index(es):
    • Date
    • Thread