![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Parsing a piece of HTML
Yo all! ^_^
I've got a web page that dynamically creates a tree-like directory structure with given input by the user. It would be in a form like the following: ...
<ul id="root">
<ul>
<li>
Dir1 <button onclick='add()'>Add another</button>
</li>
</ul>
<ul>
<li>
Dir2 <button onclick='add()'>Add another</button>
</li>
<ul>
<li>
file_in_dir2 <button onclick='add()'>Add another</button>
</li>
</ul>
</ul>
</ul>
...(Sure hope the spacing worked out ok) The overkill on the <ul> elements is so that the dir will have a tree-like structure when it is rendered in the browser. Anyhow, I need to generate an xml document from the information on the form. The things that are in the data fields are trivial, (at least they should be) but this data structrue is giving me some greef. How exactly do I pass this onto python to parse and save in the xml file? Any thoughts? Thanks! ^_^ |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
You might want to look at Beautiful Soup
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Looks interesting. I'll see if I can use that to figure it out. However, it seems that all the examples that are there only pass in html files. I'm still at a loss as to how to pass dynamic content off to python.
|
|
|
|
|
|
#4 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Sorry for being unclear. The problem I was having was exactly HOW to get the dynamcially generated string of html off the page. I made a quick trip over to the javascript section, and I can get access to it by:
document.getElementsByTagName("html")[0].innerHTMLOr something along those lines. ^_^ Thanks all! I'll play around with this and it should (by the looks of it) solve my problem. |
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Oh! You mean dynamically created by javascript, rather than a server-side language like PHP?
|
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Bear in mind that though innerHTML is supported by all recent modern graphical browsers it isn't part of the W3 standard - by all means use it, just know who your target audience. With that said you're using other JavaScript stuff for dynamically adding form elements, so you should be okay really.
|
|
|
|
|
|
#8 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Yea, I was building this with the standars in mind, but IE made my scripts cry.
I'm doing some kinda trickey stuff with this project, and unfortunatly, some anti-standard stuff had to be used to get the blasted thing to work....o.k, I guess that's a lie. I'm sure there was a way (or two or three) to get around my problems and keep to standards...but oh well. At least most of the firefox/mozilla parts are by the standard. And I do, fortunatlly, know my audience and I'm testing it on the browsers that they use. (Aside from Konqueror....poor Konqueror) |
|
|
|
|
|
#9 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Most Firefox script thingys worth with our beloved Konqueror, so you should be alright. As long as you don't use too many exotic things you should be okay - Konqueror has wonderful support for innerHTML, XmlHTTPRequest, and so on.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|