From: ruud grosmann Date: 2008-07-30T17:37:26+09:00 Subject: Re: libxml: is it possible not to use doctype declaration? hi Phill, I've tried it right away. I ended up with the following: XML::Parser.default_load_external_dtd = false XML::Parser.default_validity_checking = false XML::Parser.default_substitute_entities = false parser = XML::Parser.file( file) #parser.default_substitute_entities = false #parser.default_load_external_dtd = false #parser.default_validity_checking = false doc = parser.parse node = doc.find( xpath).first But the script still tries to resolve the entity. The doctype definition is a slightly changed real one. The message I get with the above code is: Operation in progress./tmp/ut21.uit:3: I/O warning : failed to load external entity "http://ruud.grosmann.nl/op/dtd/publicatie.dtd" e publicaties 1.0//NL" "http://ruud.grosmann.nl/op/dtd/publicatie.dtd" You were right that the methods are not instance methods, although I am not sure how to conclude that from the documentation. Did I something wrong in the script? regards, Ruud On 30/07/2008, Phill Davies wrote: > Whoops, those were supposed to be class variables. What you really want > to do (I think) is more like: > > LibXML::XML::Parser.default_load_external_dtd = false > LibXML::XML::Parser.default_validity_checking = false > > And then: > parser = LibXML::XML::Parser.file() > doc = parser.parse > > That seems to work with your example. > > Phill Davies wrote: >> To start, the rdoc documentation can be found at >> http://libxml.rubyforge.org/rdoc/index.html. Now I don't know this for >> sure, but >> >> > "http://some.site.nl/dtd/test.dtd"> >> >> doesn't look like a real doctype definition, so if you can pull it out >> of your xml (by hand, not programmatically) before trying to parse it, >> I'd say that would be a good idea. That being said, there are two >> attributes of the XML::Parser class that look like they may be of >> interest: default_load_external_dtd and default_validity_checking. Try >> setting both of those to false, unless you have a real dtd to validate >> against and the example above was fake. Of course, since this is using >> XML::Parser instead of XML::Document I think you would need to do >> e.g.: parser = XML::Parser.file() >> parser.default_load_external_dtd = false >> parser.default_validity_checking = false >> doc = parser.parse >> >> ... and then go from there. >> Phill D. >> >> Phlip wrote: >>> ruud grosmann wrote: >>> >>>> Is using libxml the right thing to do to, or are there smarter >>>> alternatives? >>> >>> Libxml-ruby is the most complete & accurate parser of the big three >>> (REXML, Libxml-ruby, and Hpricot), and its documentation can be very >>> challenging. How much of the original C Libxml documentation have you >>> been able to read? >>> >>> >> >> >> > > >