# examplea.rb -- translated to ruby from Paolo Casarini's examplea.c
#
# Copyright (C) 2001 Paolo Casarini <paolo@casarini.org>
# Copyright (C) 2001 Tobias Peters <t-peters@berlios.de>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA  02111-1307, USA.

require "gdome"

#  /* First I get a DOMImplementation reference */
domimpl = Dom::implementation

#  /* I create a new document with TEST as root element */
doc = domimpl.createDocument(nil, "TEST", nil)

#  /* I get reference to the root element of the document */
root = doc.documentElement

#  /* I set an attribute to the root element */
root.setAttribute ("PACKAGE", "gdome2")

#  /* I create a new element called RELEASE */
el = doc.createElement("RELEASE")

#  /* I create a Text Node*/
txtnode = doc.createTextNode("0.6.0")

#  /* I append the Text Node created to the childs list of the RELEASE element */
result = el.appendChild(txtnode)
if (result.gdome_id != txtnode.gdome_id)
  print("Element.appendChild: failed\n")
end

#  /* I append the RELEASE element to the childs list of the root element */
root.appendChild(el)

#  /* I save the  created document to a String */
examplea_xml = domimpl.saveDocToMemory(doc)

puts examplea_xml
