Browse files

basic parsing update

  • Loading branch information...
1 parent fbc091e commit fbc7d825e8a2d1328acc4f6d6cc2ede3728ec945 @tenderlove committed Dec 30, 2009
Showing with 19 additions and 0 deletions.
  1. +19 −0 nokogiri.markdown
19 nokogiri.markdown
@@ -76,6 +76,25 @@ Each of these strategies have different advantages and disadvantages. We
won't cover the particular differences in each, but the DOM interface is most
common and easy to use for developers, so that is the interface we'll study.
+There are two main entry points to Nokogiri depending on the kind of document
+you wish to parse, one for HTML documents and one for XML documents. Parsing
+HTML documents looks like this:
+ doc = Nokogiri::HTML(html_document)
+Parsing XML documents looks like this:
+ doc = Nokogiri::XML(xml_document)
+Both of these functions will take an IO object *or* a String object. Since
+both forms accept IO objects, we can even feed open-uri straight in to
+Nokogiri like this:
+ doc = Nokogiri::HTML(open(""))
+Feeding Nokogiri an IO object is slightly more efficient than using a String,
+but you should choose the one that is most convenient.
### Data structures
## Data Extraction

0 comments on commit fbc7d82

Please sign in to comment.