Closed ghost closed 11 years ago
Yes, you can use gokogiri to parse html into a DOM tree. As far as the DOM level supported, gokogiri is simply an interface for libxml2, so the exact DOM specification gokogiri adheres to is dependent on the DOM specification of your libxml2 library.
I am newbie, I can't find getElementById, is this need gdome2 you haven't include?
That function doesn't exist in gokogiri. You would have to use the Search(...)
function which takes in an xpath
object to conduct the source. You can read more about xpath here: http://www.w3schools.com/xpath/
Is Search(...) have a hight speed search by some mechanism? libxml2 seems no css parse support, but your project have a css directory, can you?
The css
pacakge in gokogiri provides a translational function Convert(...)
between a string that contains a CSS selector to an equivalent Xpath selector. You could use that to search the document DOM by an element's id if you'd like.
As for your first concern, the high speed search by some mechanism, I'm not sure I understand what you are referring to, could you elaborate?
can I use it to parse html, and to build a DOM tree? is it implement DOM level 2