# Xml Decleration using builder

**URL:** <https://www.ruby-forum.com/t/xml-decleration-using-builder/150975>\
**Category:** Ruby\
**Created:** [October 15, 2008, 1:52pm UTC](https://www.ruby-forum.com/t/xml-decleration-using-builder/150975 "2008-10-15T13:52:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [October 15, 2008, 1:52pm UTC](https://www.ruby-forum.com/t/xml-decleration-using-builder/150975/1 "2008-10-15T13:52:16Z")

</div>

I’m trying to create an XML file and I don’t see any way with the  
builder methods to write the doc type down.

\<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?\>

I can sucessfully using  
xml.instruct! :xml, :version =\> “1.0”, :encoding =\> “UTF-8”, :standalone  
=\> “no”

to create the first line. But the DOCTYPE line is a mystery. Any ideas?

[http://builder.rubyforge.org/](http://builder.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [October 15, 2008, 2:26pm UTC](https://www.ruby-forum.com/t/xml-decleration-using-builder/150975/2 "2008-10-15T14:26:23Z")

</div>

On Wed, Oct 15, 2008 at 1:52 PM, Dan W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to create the first line. But the DOCTYPE line is a mystery. Any ideas?  
> xml.declare! :DOCTYPE, :questestinterop, :SYSTEM, ‘ims\_qtiasiv1p2.dtd’

Got this from the README that ships with the gem.

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [October 16, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/xml-decleration-using-builder/150975/3 "2008-10-16T16:15:03Z")

</div>

```
    xml.render_choice do
      xml.render_choice(:ident => item_ident, :rcardinality => 

```

rcardinality, :rtiming =\> rtiming)  
(1…qammount).each do  
xml.response\_label do  
xml.material do  
xml.mattext(response\_mattext)  
end  
end  
end  
end

thanks for that. Should have kept on looking, I blame the man flu I had.  
I’m having issues with trying to give the parent class the tags. It’s  
straight forward giving tags that close on the same line extra items.  
e.g.

xml.render\_choice(:ident =\> item\_ident, :rcardinality =\> rcardinality,  
:rtiming =\> rtiming)

gives  
\<render\_choice ident=“NSFB\_electronics\_01\_v1p2” rcardinality=“single”  
rtiming=“No”/\>

But I need to place other tags between this. Any ideas? I can’t see  
anything in the help file to suggest that it’s possible.

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [October 17, 2008, 12:10am UTC](https://www.ruby-forum.com/t/xml-decleration-using-builder/150975/4 "2008-10-17T00:10:53Z")

</div>

On Thu, 16 Oct 2008 09:14:37 -0500, Dan W. wrote:

> ```
> end
> 
> ```
> 
> \<render\_choice ident=“NSFB\_electronics\_01\_v1p2” rcardinality=“single”  
> rtiming=“No”/\>
> 
> But I need to place other tags between this. Any ideas? I can’t see  
> anything in the help file to suggest that it’s possible.

Just add a block on the call to render\_choice

xml.instruct! :xml, :version =\> “1.0”, :encoding =\> “UTF-8”, :standalone  
xml.render\_choice do  
xml.render\_choice(:ident =\> item\_ident, :rcardinality =\>  
rcardinality, :rtiming =\> rtiming) do #here  
(1…qammount).each do  
xml.response\_label do  
xml.material do  
xml.mattext(response\_mattext)  
end  
end  
end #and here  
end  
end
