# Problems reading xml from a db field and using it in REXML

**URL:** <https://www.ruby-forum.com/t/problems-reading-xml-from-a-db-field-and-using-it-in-rexml/141764>\
**Category:** Ruby\
**Created:** [June 30, 2008, 1:55pm UTC](https://www.ruby-forum.com/t/problems-reading-xml-from-a-db-field-and-using-it-in-rexml/141764 "2008-06-30T13:55:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [June 30, 2008, 1:55pm UTC](https://www.ruby-forum.com/t/problems-reading-xml-from-a-db-field-and-using-it-in-rexml/141764/1 "2008-06-30T13:55:59Z")

</div>

I have pulled some xml from a field in the database

However, when I try to use that xml in REXML

require ‘rexml/document’  
doc = REXML::Document.new(xml)

I recieve this exception  
c:/ruby/lib/ruby/1.8/rexml/source.rb:20:in `create_from': undefined local variable or method`source’ for REXML::SourceFactory:Class  
(NameError)

This below does no raise an exception

doc = REXML::Document.new(xml.to\_s)

But I don’t think to\_s can handle the xml, as

puts doc

Gives me invalid characters.

Aidy
