473,394 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Anyone know of a small tag-based parser for parsing a text string in javascript?

Hello, I have a string that will contain a table like this:
<tr><td>column1data</td><td>column2data</td></tr>

I want to use javascript to extract the data for a given row and
column. I'm guessing the easiest would be to find a tag-based parser.
Anyone know of one?

BTW I checked out the xml parsers in javascript and I am looking for
something simpler or at least easier to use.

Thanks,
Mike
Jul 23 '05 #1
1 1341
Mike wrote:
Hello, I have a string that will contain a table like this:
<tr><td>column1data</td><td>column2data</td></tr>
This is not a table, it is merely a table row.
I want to use javascript to extract the data for a given row and
column. I'm guessing the easiest would be to find a tag-based parser.
The easiest way would be to access the DOM tree. Consider this table:

<table id="foobar">
<tr>
<td>row1column1data</td>
<td>row1column2data</td>
</tr>

<tr>
<td>row2column1data</td>
<td>row2column2data</td>
</tr>
</table>

The data of the second column of the second row, if only a text node,
can be accessed (in a DOM implementing the W3C-DOM Level 2 HTML) with

var t;
if ((t = typeof document.getElementById) == "function"
|| (t == "object" && document.getElementById))
{
var o = document.getElementById("foobar");
if (o)
{
... o.rows[1].cells[1].firstChild.nodeValue ...
}
}
Anyone know of one?
I am currently hacking on a general parser prototype for my JSdoc that could
probably be extended to handle markup languages, but it is not even alpha.
Build one yourself, ...
BTW I checked out the xml parsers in javascript
There are no XML parsers in J(ava)Script. You are confusing language(s) and
DOM(s).
and I am looking for something simpler or at least easier to use.


.... but I doubt that writing it would be simpler. I also wonder what you
find hard to use in the available parsers.
PointedEars
--
"I'm running M4.51 and..."
-- Desperate Communicator user seeking help on moz.general
Jul 23 '05 #2

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

Similar topics

3
by: S C A | last post by:
Dear All: I'm not sure if this is even possible but does anyone know about using ActiveX controls (a Microsoft-specific technology) in Java? I am having a heck of a time finding some similar...
0
by: JimM | last post by:
Whenever I paste HTML code into the .Net IDE, it automatically adds an ID attribute for HTML tags in my page that don't already have one. Is there any way to stop this behaviour? Before you...
2
by: Kate Gibbs | last post by:
I need to write a simple utility in VB.NET that reads an Excel file, gets some data from a sheet, then...it needs to automate internet explorer in a robot manner. I know that Application Centre...
3
by: scott | last post by:
Hi, Does anyone know how to enable ASPX on IIS6 ? Thanks Scott
2
by: Ken Shaw | last post by:
G'day, I'm trying to tack down any delta compression library that I could licence for use in a project. Does anyone know of a decent binary delta compression library? cheers, Ken Shaw
0
by: james | last post by:
Hi guys! I´ve got a centerd table on my site with a black 1 pixel border. What i would like to do is to add a drop shadow to the table. Anyone know if it's possible to create a drop shadow for a...
5
by: Simon Egginton | last post by:
Does anyone know how to make a CHAT ROOM for a webpage using java or jave script please. I am just look at you lot because i think you are the experts! THANK YOU! ewhost_simon"HI"@yahoo.co.uk...
12
by: Sam Halliday | last post by:
i am currently in the process of writing a program to convert a type 1 psf font file into a file compatible with the linux kernel's format for compiled-in fonts (see...
16
by: Dawn Minnis | last post by:
Hi I know you're not supposed to post OS specific questions on the newsgroup so does anyone know a good newsgroup - where there are actually people talking to eachother and not full of spam -...
2
by: Bruno Alexandre | last post by:
Hi guys, does anyone know where is the Website used in the MSDN "Lear ASP.NET 2.0 with Jeff Prosise" (http://msdn.microsoft.com/asp.net/beta2/multimedia/default.aspx) events? The website used...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.