# Problem with .to\_xml and Hash.form\_xml?

**URL:** <https://www.ruby-forum.com/t/problem-with-to-xml-and-hash-form-xml/138496>\
**Category:** Rails\
**Created:** [May 23, 2008, 6:16pm UTC](https://www.ruby-forum.com/t/problem-with-to-xml-and-hash-form-xml/138496 "2008-05-23T18:16:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![differenthink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/6bbea6/32.png) [@differenthink](https://www.ruby-forum.com/u/differenthink)\
**Post date:** [May 23, 2008, 6:16pm UTC](https://www.ruby-forum.com/t/problem-with-to-xml-and-hash-form-xml/138496/1 "2008-05-23T18:16:52Z")

</div>

Hi,

i m trying to do some kind of database dump using .to\_xml  
and after i try to fill my database back (well an other) with the  
content of the xml.

Right now i m doing that :

@xml = Video.find(:all).to\_xml(:include=\>[:vlogiciels])

it does produce :

 ..... ... ..... 

Then i try to do :

Video.new(Hash.form\_xml(@xml))

and then i ve got this error : undefined method `videos=’ for #\<Video:  
0x3f6e82c\>

I guess the problem is caused by the tag into the xml… ?  
Anyway i don t know how to solve my problem, if someone could give me  
an hand, i googled since 2hours without reel success :(…

Maybe it s a tricky question, but i m stuck ☹

Thanks

---

<div class="post-metadata">

**Author:** ![differenthink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/6bbea6/32.png) [@differenthink](https://www.ruby-forum.com/u/differenthink)\
**Post date:** [May 24, 2008, 11:09am UTC](https://www.ruby-forum.com/t/problem-with-to-xml-and-hash-form-xml/138496/2 "2008-05-24T11:09:21Z")

</div>

no one does have any clue for me ?

thanks

---

<div class="post-metadata">

**Author:** ![differenthink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/6bbea6/32.png) [@differenthink](https://www.ruby-forum.com/u/differenthink)\
**Post date:** [May 24, 2008, 9:53pm UTC](https://www.ruby-forum.com/t/problem-with-to-xml-and-hash-form-xml/138496/3 "2008-05-24T21:53:47Z")

</div>

Differenthink wrote:

> @xml = Video.find(:all).to\_xml(:include=\>[:vlogiciels])
> 
> Then i try to do :
> 
> Video.new(Hash.form\_xml(@xml))

I maybe can help a little. Instead of find(:all …, try find(:first  
… I understand that that is now what you want eventually. But, I  
think your problem is that Video.new is going to return one Video but  
your @xml is an array of Videos.

---

<div class="post-metadata">

**Author:** ![differenthink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/6bbea6/32.png) [@differenthink](https://www.ruby-forum.com/u/differenthink)\
**Post date:** [May 26, 2008, 10:37am UTC](https://www.ruby-forum.com/t/problem-with-to-xml-and-hash-form-xml/138496/4 "2008-05-26T10:37:47Z")

</div>

Thanks for your post.  
I did what you told me, i ve got an : NoMethodError: undefined method  
‘video=’ for #video:XXXX  
it seems that it didn t like the first tag …

On 24 mai, 21:53, Perry S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
