Get html DOM tree by only basic builtin moudles

Wesley nispray at gmail.com
Fri Jun 5 14:10:41 EDT 2015


Hi Laura,
  Sure, I got special requirement that just parse html file into DOM tree, by only general basic modules, and based on my DOM tree structure, draft an bitmap.

  So, could you give me an direction how to get the DOM tree?
Currently, I just think out to use something like stack, I mean, maybe read the file line by line, adding to a stack data structure(list for example), and, then, got the parent/child relation .etc

I don't know if what I said is easy to achieve, I am just trying.
Any better suggestions will be great appreciated.

Thanks.
Wesley

> Elementtree is part of the Python standard library.  You are better off
> using it than rolling your own.   (If you were one of the rare people who
> have some very strange requirements that make you better off writing your
> own, you wouldn't be asking us.  You'd already know.)
> 
> https://docs.python.org/2.7/library/xml.etree.elementtree.html#module-xml.etree.ElementTree
> https://docs.python.org/3.4/library/xml.etree.elementtree.html




More information about the Python-list mailing list