473,320 Members | 2,080 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,320 software developers and data experts.

Parsing DOM with Javascript

My problem is that i need an algorithm parse parse HTML.
For an HTML page, my script has to parse all tags to get all forms
values, even if there is frame, iframe, ...
How can i do such a script ?

Thanks

Oct 14 '05 #1
3 2443
>My problem is that i need an algorithm parse parse HTML.
For an HTML page, my script has to parse all tags to get all forms
values, even if there is frame, iframe, ...
How can i do such a script ?
gee, i dont know, can you?
Thanks


iframes may give you problems, since sometimes, you can get the access
denied msg,
other than that, i would use the innerHTML, and then some old fashoned
regexp work,
but there are probably better ways...

Oct 14 '05 #2
alu

"pipe" <au********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
My problem is that i need an algorithm parse parse HTML.
For an HTML page, my script has to parse all tags to get all forms
values, even if there is frame, iframe, ...
How can i do such a script ?


gee, i dont know, can you?
Thanks


iframes may give you problems, since sometimes, you can get the access
denied msg,
other than that, i would use the innerHTML, and then some old fashoned
regexp work,
but there are probably better ways...

I was hoping someone in-the-know would respond to this request,
as I'm interested in a solution myself.
Your subject line is "parsing the DOM", while your post
implies simply parsing HTML tags.
If that's the case, I've done this before by simply placing each tag into
an array element. This could be easily adapted to include iframes
and frames, the content of which must be within the same domain.
Very crude solution....

// -------------------------------

// array to hold all html tags
arrayOfTags = new Array();
// populate array
function parseHTML(HTMLcontent) {
// split at <
var re = "<"
arrayOfTags = HTMLcontent.split(re)
// restore split separator

for (var i = 1; i < arrayOfTags.length; i++) {
arrayOfTags[i] = "<" + arrayOfTags[i]
}
}

function outPut(n) {
alert(arrayOfTags[n])
}

// -------------------------------------

<div onclick="outPut(1)">click to see array element 1</div>

-alu
Oct 15 '05 #3
djdave wrote:
My problem is that i need an algorithm parse parse HTML.
For an HTML page, my script has to parse all tags to get all forms
values, even if there is frame, iframe, ...
How can i do such a script ?


Iterate and recurse through the `frames' collection, access the `forms'
collections of the respective `document' properties/objects and access
their `elements' collections. Whatever you consider "form values", you
may want to look for elements with specific `type' property/attribute
values.

However, there is already a bookmarklet for this, though I have not
tested or analyzed if it works with frames:

<http://www.squarefree.com/bookmarklets/forms.html>

implemented in

<http://chrispederick.com/work/webdeveloper/documentation/features/forms/>
HTH

PointedEars
Oct 18 '05 #4

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

Similar topics

16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
3
by: Hilton Lima | last post by:
Hi there; I have the following problem. I am using one of the many javascript XML parsing scripts available around the Internet, but the parsing fails when it reach an XML child node that is...
5
by: Martin Walke | last post by:
Hi all, Can someone help me out here? I'm been using ASP and VBScript for some years but have just ventured into the realms of using server side Javascript and apart from hitting various...
0
by: bruce | last post by:
hi... it appears that i'm running into a possible problem with mechanize/browser/python rgarding the "select_form" method. i've tried the following and get the error listed: br.select_form(nr...
3
by: Rodrigo Meza | last post by:
Hello Everyone For a project I am working on, I need to retrieve links from html documents. The easy part is to obtain 'plain' links like <A HREF="http://site/path/document">, but when those...
6
by: jackwootton | last post by:
Hello everyone, I understand that XML can be parsed using JavaScript using the XML Document object. However, it is possible to parse XHTML using JavaScript? I currently listen for DOMMutation...
0
by: bruce | last post by:
Hi... I've got a couple of test apps that I use to parse/test different html webpages. However, I'm now looking at how to parse a given site/page that uses javascript calls to dynamically...
1
by: avpkills2002 | last post by:
I seem to be getting this weird problem in Internet explorer. I have written a code for parsing a XML file and displaying the output. The code works perfectly fine with ffx(Firefox).However is not...
1
by: Philip Semanchuk | last post by:
On Oct 12, 2008, at 5:25 AM, S.Selvam Siva wrote: Selvam, You can try to find them yourself using string parsing, but that's difficult. The closer you want to get to "perfect" at finding URLs...
16
by: freefony | last post by:
Am trying to parse a php array into javascript but i found that only one element of the array was present in the javascript array. here is my code code <?php include("../../connect.php");...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.