Project

nom-xml

0.01
Low commit activity in last 3 years
No release in over a year
NOM allows you to define a “terminology” to ease translation between XML and ruby objects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.1
>= 0

Runtime

>= 0
 Project Readme

nom-xml

A library to help you tame sprawling XML schemas.

nom-xml allows you to define a “terminology” to ease translation between XML and ruby objects – you can query the xml for Nodes or node values without ever writing a line of XPath. nom-xml is built on top of nokogiri decorators, which means you can mix-and-match NOM accessors with nokogiri xpaths, xml manipulation, and traversing and it will just work.

Some Handy Links

Here are some resources to help you learn more about nom-xml:

  • API - A reference to nom-xml's classes

An Example

<?xml version="1.0"?>
<!-- from http://www.alistapart.com/d/usingxml/xml_uses_a.html -->
<nutrition>
<food>
	<name>Avocado Dip</name>
	<mfr>Sunnydale</mfr>
	<serving units="g">29</serving>
	<calories total="110" fat="100"/>
	<total-fat>11</total-fat>
	<saturated-fat>3</saturated-fat>
	<cholesterol>5</cholesterol>
	<sodium>210</sodium>
	<carb>2</carb>
	<fiber>0</fiber>
	<protein>1</protein>
	<vitamins>
		<a>0</a>
		<c>0</c>
	</vitamins>
	<minerals>
		<ca>0</ca>
		<fe>0</fe>
	</minerals>
</food>
</nutrition>
require 'nom/xml'

# load the source document as normal
doc = Nokogiri::XML my_source_document

doc.set_terminology do |t|
  t.name

  t.vitamins do |v|
    v.a
    v.c
  end

  t.minerals do |m|
    m.calcium :path => 'ca'
    m.iron :path => 'fe'
  end
end

doc.nom!

doc.name.text == 'Avocado Dip'
doc.minerals.calcium.text == '0'