Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend XML::Reader with more LibXML methods (#5740)
* Extend XML::Reader with more LibXML methods This adds a couple of method bindings that come in handy when doing pull parsing or hybrid parsing (search with pull then expand node). * Work around incomplete xmlTextReaderNextSibling() The current implementation of xmlTextReaderNextSibling() only works on preparsed documents, so we need to detect the error returned if the reader is not using a preparsed document and implement our own next sibling by looking at reader internals. * Fix XML::Reader#name/#value when not on node This avoids segfaults when those methods are called before the first or after the last read. * Add XML::Type::NONE for XML::Reader#node_type This fixes a problem where XML::Reader#node_type would return zero before the first or after the last read, which previously had no mapping in the XML::Type enum, so the value couldn't be checked. * Document all XML::Reader methods * Add specs for all XML::Reader methods * Avoid Nil for XML::Reader string getters instead return an empty string if the methods are called in an invalid reader state (before the first or after the last read). A special case is the #value method, which could also return nil if called on a node without a text value, like `<tag>`, but here an empty string also makes sense. * Use explicit type for XML:Reader attribute methods * Rename XML::Reader#attribute to #[]/#[]? and implement behavior similar to XML::Node.
- Loading branch information