Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I want to return the html and text of a selection on a web page

Posted on 2010-11-29
8
Medium Priority
?
458 Views
Last Modified: 2012-08-13
Public ie
ie=Createobject('internetexplorer.application')
ie.Visible=.T.
iet.navigate2("www.somewhere.com")

Open in new window


I want to be able to highlight a section of a webpage and from foxopro return the text of the selection and return the html of the selection simular to firefox's copy selected html function. I know there is a way, I have just forgeotten it. :(

Thanks again all!!!!!!
0
Comment
Question by:busycoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34236485
? ie.Document.Body.InnerText

You can use GetElementByName('ElementName').InnerText or InnerHTML
0
 

Author Comment

by:busycoder
ID: 34236760
I want to only return the text of what I have selected on a given page with the mouse.

Ie.document.selection (I think is where to start)

I want to the HTML of that portion only. I know I figured this out before but am drawing a blank still.
0
 
LVL 27

Accepted Solution

by:
CaptainCyril earned 1000 total points
ID: 34236797
0
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34236799
0
 
LVL 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 1000 total points
ID: 34237391
Youre on the right track. The problem is, VFP does not display the methods and properties of the selection object by intellisense, if you type Ie.document.selection, VFP does not even display the selection subobject of ie.document, even though it's there. That's a bit of a glitch of VFP's intellisense, VFP can only display what it can see, the selection subobject seems somehow virtual, created on the fly as you access it. You can do so, by storing it to a VFP variable:

oDoc = ie.document

Now you can see oDoc.selection and it's methods and the type property.  And you can also see there is a createRange method (which the reference Cyril gave you also tells - http://msdn.microsoft.com/en-us/library/ms535869%28VS.85%29.aspx). And the Range object has a htmlText property giving you the HTML of the selection.

I did only learn that right now by inspection via intellisense, it was simply try and error, there was not much more I could test, the selection object itself has not many choices. The general idea I want to share is, that you can do that too and learn from intellisense. And if intellisense seems blind or dim, enlighten it by creating a new root object in a new variable and it most probably can see further from there.

Now here's the full code:

oIE = Createobject('internetexplorer.application')
oIE.Visible = .T.
oIE.navigate2("www.somewhere.com")

* make a selection of some text portion

oDoc = oIE.document
oTextRange = oDoc.selection.createRange()
? oTextRange.htmlText
? oTextRange.Text

Open in new window

0
 

Author Closing Comment

by:busycoder
ID: 34268065
Thank you again guys!! Olaf, I think you told me about the intellisense trick before, but I didn't get it, thanks for telling me again, that is VERY valuable. CaptainCyril, thank you again for some great reference links as always. You both are always such a HUGE help to me. Lets do lunch!
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34268402
Where? In Beirut, Lebanon? Anytime :-)
0
 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 34273245
Of course we could lunch together somewhere.com, sometimes.com

Bye, Olaf.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
In this article, WatchGuard's Director of Security Strategy and Research Teri Radichel, takes a look at insider threats, the risk they can pose to your organization, and the best ways to defend against them.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question