473,548 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2454
>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********@gma il.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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(HTMLc ontent) {
// split at <
var re = "<"
arrayOfTags = HTMLcontent.spl it(re)
// restore split separator

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

function outPut(n) {
alert(arrayOfTa gs[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.c om/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
2862
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 loaded into cache, the slideshow doesn't look very nice. I am not sure how/when to call the slideshow() function to make sure it starts after...
3
12068
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 empty, as in the example below: <FirstName>John</FirstName> <MiddleInitial></MiddleInitial> <LastName>Smith</LastName> John Smith does not have a...
5
1753
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 niggerly problems, this one baffles me. This is a very simplistic example of the problem. <%@ Language="JavaScript"%>
0
2368
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 = 1) br.select_form(name="foo") br.select_form(name=foo) br.select_form(name="foo")
3
1901
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 links are javascript'ized, the only robust solution needs to load the javascript and dom document representation in the same way that browsers do. For...
6
5912
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 events, when the events occur I access the node which was inserted or removed (event.target). There is only ever about 5 lines of XHTML nested in...
0
951
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 create/display the resulting HTML. I can see the HTML is the Browser page if I manually select the btn that invokes the javascript function, but I have...
1
4815
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 working in Internet Explorer.(I m using Internet Explorer 6.0). The code is as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
1
2857
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 expressed in JS, the closer you'll get to rewriting a JS interpreter. For instance, this is not so hard to understand: "http://example.com/" but...
16
9271
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"); $qry="select * from stock"; $rst=mysql_query($qry) or die("Error in Query.".$qry." ".mysql_error()); while($row=mysql_fetch_assoc($rst)){ $item=$row;...
0
7512
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
7951
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...
1
7466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7803
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5082
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
3495
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...
1
1926
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
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.