moovweb / gokogiri

A light libxml wrapper for Go
MIT License
600 stars 95 forks source link

is it implement DOM level 2 #24

Closed ghost closed 11 years ago

ghost commented 11 years ago

can I use it to parse html, and to build a DOM tree? is it implement DOM level 2

mdayaram commented 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.

ghost commented 11 years ago

I am newbie, I can't find getElementById, is this need gdome2 you haven't include?

mdayaram commented 11 years ago

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/

ghost commented 11 years ago

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?

mdayaram commented 11 years ago

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?