• 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: DOMNode problems getting info out...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DOMNode problems getting info out...


  • Subject: Re: DOMNode problems getting info out...
  • From: jon <email@hidden>
  • Date: Sun, 23 Aug 2009 11:45:59 -0600

ok, this seems mighty round about, but this works.... let me know if you think there is a simpler way... i found atleast two sets of documentation on this from "developer/Apple" on DomNodes or DOMObjects neither had the same info... but combining the two, i think i figured it out...


DOMDocument *myDOMDocument = [[myWebView mainFrame] DOMDocument]; DOMNodeList *allParas = [myDOMDocument getElementsByTagName:@"p"];

	DOMNode *node = [allParas item:0];

	DOMNodeList *nodeList = [node childNodes];


DOMHTMLLinkElement* link = (DOMHTMLLinkElement*)[nodeList item:1];


        NSString* href = [link href];

	NSString *top = [node textContent];


now href conatins a string with the link in it, and top contains the rest of the text within the "paragraph"...
this is the paragraph example again:


<p> Aug 19 - <a href="http://whatever/sys/1331140637.html";>Two 1GB Apple matched pair RAM from a MacBook - $30 -</a><font size="-1"> (Louisville )</font></p>

Jon.





On Aug 23, 2009, at 8:06 AM, jon wrote:

I have found that there is extremely limited documentation dealing with DOMNodeLists and DOMNode...

for instance i found by pure accident that textContent works on a node, and found no documentation on it... and lots references to getAttribute or getElementID but can not get them to work...

so here is what i'm trying to do with code and maybe someone has figured this out...

thanks in advance..

here is some data in some HTML that I would like to parse, i've found how to get the text out, but i can't get this URL out....

<p> Aug 19 - <a href="http://whatever/sys/1331140637.html";>Two 1GB Apple matched pair RAM from a MacBook - $30 -</a><font size="-1"> (Louisville )</font></p>


here is the code i'm using to parse it.... most of it works, including the textContent, last two lines don't work...trying to get this "http://whatever/sys/1331140637.html"; into a NSString, or NSURL is failing me...



DOMDocument *myDOMDocument = [[myWebView mainFrame] DOMDocument]; DOMNodeList *allParas = [myDOMDocument getElementsByTagName:@"p"];

	DOMNode *node = [allParas item:0];

	NSString *top = [node textContent];


NSString *top2 = [node getAttribute:@"href"]; // this is way off, just trying to find methods, but i expected getAttribute to atleast be acknowledged as a method????
NSString *top4 = [node getElementById:@"href"]; // this is way off, but i expected getElementById to atleast be acknowledged as a method????



any help would be great... thanks, Jon.

_______________________________________________

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


References: 
 >DOMNode problems getting info out... (From: jon <email@hidden>)

  • Prev by Date: DOMNode problems getting info out...
  • Next by Date: Drawing over a transparent background
  • Previous by thread: DOMNode problems getting info out...
  • Next by thread: Drawing over a transparent background
  • Index(es):
    • Date
    • Thread