# Ruby and XML, validation and DOM

**URL:** <https://www.ruby-forum.com/t/ruby-and-xml-validation-and-dom/50578>\
**Category:** Ruby\
**Created:** [December 18, 2005, 3:00pm UTC](https://www.ruby-forum.com/t/ruby-and-xml-validation-and-dom/50578 "2005-12-18T15:00:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gendag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gendag](https://www.ruby-forum.com/u/gendag)\
**Post date:** [December 18, 2005, 3:00pm UTC](https://www.ruby-forum.com/t/ruby-and-xml-validation-and-dom/50578/1 "2005-12-18T15:00:50Z")

</div>

Hi all,  
I’ve started to learn Ruby two days ago and it’s fantastic! 🙂  
I need I help, i need a lib to validate a XML file and to create  
a DOM tree. I’ve search in the web but I didn’t find anuthing, in truth  
I’ve found libxml for tuby but I didn’t find any documentation for the  
API…

Thx to all that can halp me

Gendag

---

<div class="post-metadata">

**Author:** ![gendag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gendag](https://www.ruby-forum.com/u/gendag)\
**Post date:** [December 18, 2005, 4:13pm UTC](https://www.ruby-forum.com/t/ruby-and-xml-validation-and-dom/50578/2 "2005-12-18T16:13:01Z")

</div>

On Sun, 18 Dec 2005 13:56:16 -0000, Gendag  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I need I help, i need a lib to validate a XML file and to create  
> a DOM tree. I’ve search in the web but I didn’t find anuthing, in truth  
> I’ve found libxml for tuby but I didn’t find any documentation for the  
> API…

Not that this is much help right now, but I am working on on some basic  
documentation for the current libxml codebase. I’ll put it up somewhere  
as  
an interim measure either today or tomorrow. I’ll post a link when it’s  
ready.

---

<div class="post-metadata">

**Author:** ![gendag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gendag](https://www.ruby-forum.com/u/gendag)\
**Post date:** [December 18, 2005, 5:28pm UTC](https://www.ruby-forum.com/t/ruby-and-xml-validation-and-dom/50578/3 "2005-12-18T17:28:19Z")

</div>

On Sunday 18 December 2005 08:57 am, Gendag wrote:

> Hi all,  
> I’ve started to learn Ruby two days ago and it’s fantastic! 🙂  
> I need I help, i need a lib to validate a XML file and to create  
> a DOM tree. I’ve search in the web but I didn’t find anuthing, in truth  
> I’ve found libxml for tuby but I didn’t find any documentation for the  
> API…

I don’t think it validates, so this may not help, but Rexml is a _great_  
API  
for XML parsing, and it comes with Ruby.

---

<div class="post-metadata">

**Author:** ![gendag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gendag](https://www.ruby-forum.com/u/gendag)\
**Post date:** [December 18, 2005, 5:37pm UTC](https://www.ruby-forum.com/t/ruby-and-xml-validation-and-dom/50578/4 "2005-12-18T17:37:20Z")

</div>

On Dec 18, 2005, at 6:57 AM, Gendag wrote:

> I’ve started to learn Ruby two days ago and it’s fantastic! 🙂  
> I need I help, i need a lib to validate a XML file and to create  
> a DOM tree.

I highly recommend REXML for creating the DOM tree and working with  
the XML. But I don’t believe it does DTD/Schema validation.

Thankfully, there seem to be lots of other programs and web services  
that do this bit. Although it would be nice to wrap it all up into  
one nice little package, how about doing both with separate pieces?

For example, start here [http://www.cogsci.ed.ac.uk/~richard/xml-](http://www.cogsci.ed.ac.uk/~richard/xml-)  
check.html  
If you don’t choose to use that web service, perhaps the software it  
links to (or the software that the pages it links to themselves link  
to) will help. Remember that Ruby can invoke programs from the shell/  
command line, and retrieve the results.

---

<div class="post-metadata">

**Author:** ![gendag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gendag](https://www.ruby-forum.com/u/gendag)\
**Post date:** [December 19, 2005, 5:30am UTC](https://www.ruby-forum.com/t/ruby-and-xml-validation-and-dom/50578/5 "2005-12-19T05:30:09Z")

</div>

On Sun, 18 Dec 2005 15:04:46 -0000, Ross B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> documentation for the current libxml codebase. I’ll put it up somewhere  
> as an interim measure either today or tomorrow. I’ll post a link when  
> it’s ready.

First cut is up on my site:

```
http://roscopeco.co.uk/projects/libxml-ruby/

```

It’s quite basic but it has the all-important ‘what methods does it  
have’  
thing about it. It covers the last version released by Trans (I think?),  
version 0.3.4-04.04.14.

Please be advised that a few bugs have been found:

```
* Problems with the default validation on XML::Parser (DTD/Schema
  validation should be unaffected)

* Some small memory leaks across the library

* Incompatibilities with GCC 4.0

* Moving nodes between Node/NodeSet operations can cause segfault at
  Ruby exit.

* XPointer/XPath range support is buggy.

```

However I have the critical stuff patched up here and hopefully we’ll be  
able to get an interim release out very soon.

NOTE:  
The URL above is temporary, so if you’re reading from archives it’ll  
probably be a redirect to libxml on rubyforge. We (or I anyway) just  
aren’t quite sure where that is yet ;))

---

<div class="post-metadata">

**Author:** ![gendag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gendag](https://www.ruby-forum.com/u/gendag)\
**Post date:** [December 19, 2005, 3:35pm UTC](https://www.ruby-forum.com/t/ruby-and-xml-validation-and-dom/50578/6 "2005-12-19T15:35:37Z")

</div>

Ross B. wrote:

> First cut is up on my site:
> 
> ```
> http://roscopeco.co.uk/projects/libxml-ruby/
> 
> ```
> 
> [cut]

I want to thank all for their answers, I’ve tried Rexml and I like  
it, but I think it doesn’t validate. Now I’ll read your documentation  
to know how libxml for Ruby works, thanks for the link 🙂

bye!

Gendag
