class Nokogiri::XML::SyntaxError - nokogiri-1.8.0 Documentation

# class Nokogiri::XML::SyntaxError

The XML::SyntaxError is raised on parse errors

This class provides information about XML SyntaxErrors. These exceptions are typically stored on Nokogiri::XML::Document#errors.

### Attributes

code[R]
column[R]
domain[R]
file[R]
int1[R]
level[R]
line[R]
str1[R]
str2[R]
str3[R]

### Public Instance Methods

error?() click to toggle source

return true if this is an error

    # File lib/nokogiri/xml/syntax_error.rb, line 32
    def error?
      level == 2
    end

fatal?() click to toggle source

return true if this error is fatal

    # File lib/nokogiri/xml/syntax_error.rb, line 38
    def fatal?
      level == 3
    end

none?() click to toggle source

return true if this is a non error

    # File lib/nokogiri/xml/syntax_error.rb, line 20
    def none?
      level == 0
    end

to_s() click to toggle source
Calls superclass method

    # File lib/nokogiri/xml/syntax_error.rb, line 42
    def to_s
      message = super.chomp
      [location_to_s, level_to_s, message].
        compact.join(": ").
        force_encoding(message.encoding)
    end

warning?() click to toggle source

return true if this is a warning

    # File lib/nokogiri/xml/syntax_error.rb, line 26
    def warning?
      level == 1
    end

### Private Instance Methods

level_to_s() click to toggle source

    # File lib/nokogiri/xml/syntax_error.rb, line 51
    def level_to_s
      case level
      when 3 then "FATAL"
      when 2 then "ERROR"
      when 1 then "WARNING"
      else nil
      end
    end

location_to_s() click to toggle source

    # File lib/nokogiri/xml/syntax_error.rb, line 64
    def location_to_s
      return nil if nil_or_zero?(line) && nil_or_zero?(column)
      "#{line}:#{column}"
    end

nil_or_zero?(attribute) click to toggle source

    # File lib/nokogiri/xml/syntax_error.rb, line 60
    def nil_or_zero?(attribute)
      attribute.nil? || attribute.zero?
    end