QuiXML

What is QuiXML?

Download

Install

The QuiXML API

QuiXML at
RubyForge

A fast Ruby XML API written in C with pretty-printing, entity en-/decoding, marshalling and regex addressing.

Copyright © 2003 Sean O'Dell <sean@celsoft.com>
QuiXML is released under the GNU General Public License

current version: 0.2.1 (changelog)
release date: Sun Aug 31 20:40:15 PDT 2003
download quixml-0.2.1.tar.gz now

What is QuiXML?

QuiXML is an XML library for Ruby. It...

...is written in C, utilizing James Clark's expat library, so it's very fast.

...uses only Ruby native data structures to store its XML data internally, so there is no "built-in" way to create XML trees; how they are generated is completely open.

...both parses and generates XML, automatically performing pretty printing and encoding/decoding special characters (<, >, &, ', and ").

...can transmutate attribute string values to/from Ruby objects when reading/writing XML, allowing for a limited degree of object marshalling.

...uses literal strings, regular expressions or any other object which supports Ruby case-equality to find matching nodes by name and attribute values.

Example Code:

require "quixml"

qxml = QuiXML::Tree.new

# parse and transmutate attributes
qxml.parse(xmlstring) do | name, value |
  case name
    when "active"
      value == "yes" ? true : false
    when "id"
      value.to_i
    else
      value
  end
end

# find the node /root/acc whose id is 123
node = qxml.find_first(["root", ["acc", "id", 123]])

p node.attributes #<-- {"acc"=>123, "active"=>true}

Download

The latest major version is 0.2.1, and you can download it here:

quixml-0.2.1.tar.gz

You can find more current versions here:

QuiXML file repository at RubyForge

Install

First, unpack the file name:

tar -xzvf quixml-0.2.1.tar.gz

Then, run these commands from the shell to build QuiXML:

cd quixml-0.2.1
./configure
make

Then as root, run this command to install QuiXML:

make install

Change Log

===> 0.2.1:

--- 08/31/2003

Found a major typo in the docs regarding parsing flags. Can't have that.

===> 0.2.0:

--- 08/31/2003

Added quixml::create_node which creates a node as a hash which contains all of the expected properties (name, attributes, children, text). Strictly for convenience.

Added example code to every method in the docs.

Change the "programming with" section in the docs to be more exemplary and less lecturing.

--- 08/30/2003

quixml::parse, quixml::tree.parse and quixml::tree.to_xml all now take an optional parameter which is a flag of bitwise values which control how XML is parsed and output.

Output didn't quite adhere to its own rules; fixed that.

--- 08/29/2003 sdodell

More distribution fine-tuning. Better version reporting on the home page, generally more automated.

Added find_content method.

Changed named of find_content to content_of

find_all now calls a block if given.

Renamed internal functions to better differentiate between class and instance methods.

Added class method parse to create a tree directly from xml. It calls a block same as parse.

Added class method with_node which uses a node as the root for a new quixml::tree and passes the tree as the parameter to a block.

Added attributes_of and children_of and changed content_of to text_of.

The term "content" is replaced completely with the term "text" everywhere.

When element addressing is performed, the value "." automatically always matches the root node now.

More internal cleanups; renaming of things here and there.

Added constants for better control over parsing and printing regarding extra whitespace, data mixed with elements and tag appearance.

===> 0.1.1:

--- 08/29/2003 sdodell

Fixed the distribution build so it decompresses in its own directory.

===> 0.1.0:

--- 08/28/2003 sdodell

Tuned makedist.rb

Completely re-analyzed how memory was being handled and changed just about everything related to garbage collection. First, since no Ruby values or memory blocks were being kept by QuiXML::Tree, removed all rb_gc_reg/unreg type of calls; theoretically, the garbage collector should know how to handle all that, so I took my hands off it all. Then, I changed all the structures that were being created on the stack to be created by ALLOCA_N, which will "mark" any values or memory blocks kept by the structures. There was a bug where the garbage collector was collecting memory I had allocated with malloc because it was being allocated in a stack frame deeper than the caller, and was getting unmarked.

In a nutshell, memory should be very well taken care of now.

--- 08/27/2003 sdodell

Switched to Ruby-allocated memory; that should stop any potential leaks.

Fixed a problem where the wrong variable holding a node value was registered with the GC.

Fixed a crash bug caused by a global variable whose storage fell off the stack.

Fixed the whitespace stripping.

Copyright © 2003 Sean O'Dell <sean@celsoft.com>