https://github.com/cbeer/nom-xml
https://github.com/cbeer/nom-xml
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cbeer/nom-xml
- Owner: cbeer
- License: other
- Created: 2012-09-11T18:50:36.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2022-08-02T14:42:39.000Z (almost 3 years ago)
- Last Synced: 2025-04-13T21:04:31.311Z (about 2 months ago)
- Language: Ruby
- Size: 103 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this 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](http://nokogiri.org) 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](http://rubydoc.info/github/cbeer/nom-xml) - A reference to nom-xml's classes
An Example
---------------```xml
Avocado Dip
Sunnydale
29
11
3
5
210
2
0
1
0
0
0
0
```
```ruby
require 'nom/xml'# load the source document as normal
doc = Nokogiri::XML my_source_documentdoc.set_terminology do |t|
t.namet.vitamins do |v|
v.a
v.c
endt.minerals do |m|
m.calcium :path => 'ca'
m.iron :path => 'fe'
end
enddoc.nom!
doc.name.text == 'Avocado Dip'
doc.minerals.calcium.text == '0'
```