XML::Magick

About

XML::Magick allows you to parse an xml document or string, and access fields/attributes using ruby objects.

Install


$ gem install <notextile>mig-xml_magick</notextile>

Usage


    require 'rubygems'
    require 'xml_magick'

    xml = %Q{
      <project title="XML Magick">
        <x:content xmlns:x='http://www.w3.org/1999/XSL/Transform'>I am content</x:content>
        <type>Library</type>
        <contact name="Mig">[email protected]</contact>
        <contact name="Rig">[email protected]</contact>
        <contact name="Pig">[email protected]</contact>
        <description>Describe the situation</description>
      </project> 
    }

    @magick = XML::Magick.new(xml)

    @magick.description #=> Describe the situation
    @magick[:title] #=> XML Magick
    @magick.contact[1].xml_content #=> [email protected]
    @magick.contact[2][:name] #=> Pig
    @magick.namespace = "x:http://www.w3.org/1999/XSL/Transform"
    @magick.content #=> I am content