Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Anyone know of a small tag-based parser for parsing a text string in javascript?

Reply
Thread Tools

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

 
 
Mike
Guest
Posts: n/a
 
      08-20-2004
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
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      08-21-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone know of a MICR parser algorithm written in Python? mkppk Python 4 03-25-2007 06:04 PM
does anyone know a working ticker/parser for stocks Oliver Bleckmann Perl Misc 1 06-10-2005 11:00 PM
LOOK! i just want to know does anyone know... Simon Egginton Javascript 3 07-26-2004 08:11 PM
I know, I know, I don't know Andries Perl Misc 3 04-23-2004 02:17 AM
anyone know of a small java browser nileppez Java 0 08-18-2003 06:09 PM



Advertisments