tenderlove/nokogiri — Issue #613: Nokogiri 1.5.0 on libxml2 2.7.8 reading HTML line numbers as "0"
Author: kwhitaker
Created: 2012-02-07 14:38:05+00:00
State: open

Attempting to parse HTML files on CentOS5, running ruby 1.9.2, nokogiri 1.5.0, and libxml2 2.7.8.

Parsing a file with syntax like this:

```ruby
html = Nokogiri::HTML(File.read('index.html'))
html.css("a").each {|href| puts href.line}
```
results in "0" for every line number. If I instead parse it as xml:

```ruby
html = Nokogiri::XML(File.read('index.html'))
```

the line numbers will be displayed correctly. I know there was a previous issue with libxml2 2.7.3, and I also know that CentOS comes with libxml2 2.6.2. However, I've followed the tutorial for installation on the site, and built Nokogiri against libxml2 2.7.8. Here's my nokogiri -v output:

```text
# Nokogiri (1.5.0)
---
warnings: []

nokogiri: 1.5.0
ruby:
version: 1.9.2
platform: x86_64-linux
description: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
engine: ruby
libxml:
binding: extension
compiled: 2.7.8
loaded: 2.7.8
```
I do still technically have libxml 2.6.2 installed on the system via yum, but it doesn't look like it's affected the nokogiri build. Is there some other step I should be using?

As an aside, if I must end up using Nokogiri::XML to parse the html, will it work with HTML4 and HTML5 documents, as well as XHTML?

Thanks.