473,569 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting text (cross platform)

Is there a standard way to extract text from a web page, without using
innertext/innerhtml?

It's an academic exercise, and we've been advised that we can't use
Internet Explorer DOM extensions that are not part of the W3C DOM.

Thanks,

Debbie

Jul 16 '06 #1
2 1565


Debbie wrote:
Is there a standard way to extract text from a web page, without using
innertext/innerhtml?

It's an academic exercise, and we've been advised that we can't use
Internet Explorer DOM extensions that are not part of the W3C DOM.
Well then use the W3C DOM, text will sit in text nodes as leaf nodes of
the DOM tree and each text node has a property named nodeValue that will
give you the text in the text node. You could also use the data property
for that.
If you want the text in an element then you will either have to go
through the child nodes and concatenate the text of the child nodes
(where you might have to recursively go down the tree until you have the
text nodes) or depending on your needs and requirements you can use the
W3C DOM Level 3 property named textContent which Mozilla has been
supporting for quite some time and which at least Opera supports too now.
Then there is the W3C DOM Level 2 Range API that also allows you to get
the text in a range so you could position the range on an element node
and call toString on the range e.g.
var range = document.create Range();
range.selectNod eContents(someN ode);
var text = range.toString( );
Mozilla and Opera 8 and later support the Range API.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 16 '06 #2
Thank you, Martin, that does just what I was looking for.

Regards,

Debbie

Jul 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2336
by: Christopher Subich | last post by:
As a hobby project, I'm writing a MUD client -- this scratches an itch, and is also a good excuse to become familiar with the Python language. I have a conceptual handle on most of the implementation, but the biggest unknown for me is the seemingly trivial matter of text display. My first requirement is raw speed; none of what I'm doing is...
7
4815
by: Web Master | last post by:
Are there any good websites or books that deal with cross platform XML? I'd like to target Internet Explorer/Netscape Navigator 5 or later, as well as Opera, possibly konqueror on Linux as well. OT: I'm also looking for books and websites for cross platform XHTML and DHTML.
0
2038
by: demibee | last post by:
Thought this might be of interest to some out there... For those who've never encountered it, it's a free, open-source, cross-platform GUI library (Windows/Mac/Linux). Forte's Agent 2.0 will be built with it. AVG is as well.. "wxWindows An open source C++ GUI framework to make cross-platform programming child's play." ...
29
3424
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
6
2177
by: saleemahmad70 | last post by:
Hi.. I am stuck with a problem where I need to extract some information from a File in C++.e.g File size,date of creation, Location on the Disk etc. I haven't been able to find any particular solution yet. Could anybody amongst you help me in this regard. I'll be glad. Regards; Saleem
7
2622
by: Charles | last post by:
I'd like to develop a simple cross-platform application in C++. I'd like it to run in Windows, OS X, PC-BSD and Linux. From my research, it seems I should use Qt or Gtk as a graphical library. Do you agree? Do you have other tips? How Cygwin could help me? Thanks.
5
10077
by: Michael Reichenbach | last post by:
After working with script languages, notepad(++) and co. and several other ide`s I found something which really improved my productivity (Visual Studio 2005). It`s imho better then dev-cpp... I worked with C# and VB.net a bit and it was really easy because of the debugger, the interactive debugger, intellisense, command completer and so on. ...
1
7809
by: Vinod Sadanandan | last post by:
Cross Platform Migration An Unproblematic Approach (Windows-UNIX ) Oracle 10\11g The principal restriction on cross-platform transportable database is that the source and destination platform must share the same endian format. Redo log files and control files from the source database are not transported to destination database . New control...
42
2547
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I'm currently writing a program and I've got in mind to keep it as portable as possible. In particular I want it to run on Linux and Windows, but I'm also keeping an open mind to any machine that has a screen and is capable of Ethernet networking. The program requires three things that aren't available in the C Standard: 1) Coloured text (for...
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.