rexml/document : one tag not closing

A

Aldric Giacomoni

Ruby 1.8.6 on Windows. The following code runs fine.. But I don't get
the </DataSource> that I expect between </ConnectionString> and
</DataSources>. I can't figure out what I'm doing wrong..

require 'rexml/document'
doc = REXML::Document.new
datasource = doc.add_element 'DataSources'
datasource.add_element( 'DataSource', {'Name' => 'LOCAL', 'Type' =>
"Cedara DbS P10", 'Default' => '',
'MaxLimit' => 500})
schema = datasource.add_element 'Schema'
schema.add_text "DbSP10Schema.xml"
connectionstring = datasource.add_element 'ConnectionString'
connectionstring.add_text "Provider=ISG OLE DB DbS Provider; Data
Source=localhost:3205"

doc.write

Thanks,

--Aldric
 
R

Robert Klemme

Ruby 1.8.6 on Windows. The following code runs fine.. But I don't get
the </DataSource> that I expect between </ConnectionString> and
</DataSources>. I can't figure out what I'm doing wrong..

require 'rexml/document'
doc = REXML::Document.new
datasource = doc.add_element 'DataSources'
datasource.add_element( 'DataSource', {'Name' => 'LOCAL', 'Type' =>
"Cedara DbS P10", 'Default' => '',
'MaxLimit' => 500})
schema = datasource.add_element 'Schema'
schema.add_text "DbSP10Schema.xml"
connectionstring = datasource.add_element 'ConnectionString'
connectionstring.add_text "Provider=ISG OLE DB DbS Provider; Data
Source=localhost:3205"

doc.write

This is because you did not add nested elements to DataSource. My
output looks like this

irb(main):013:0* doc.write
<DataSources><DataSource MaxLimit='500' Name='LOCAL' Default=''
Type='Cedara DbS
P10'/><Schema>DbSP10Schema.xml</Schema><ConnectionString>Provider=ISG
OLE DB DbS Provider; Data
Source=localhost:3205</ConnectionString></DataSources>=> [<?xml ... ?>,
<DataSources> ... </>]

This is because you probably confused DataSources and DataSource. Your
variable named "datasource" holds DataSources and so you add Schema to
that instead of to DataSource.

Kind regards

robert
 
A

Aldric Giacomoni

Robert said:
Ruby 1.8.6 on Windows. The following code runs fine.. But I don't get
the </DataSource> that I expect between </ConnectionString> and
</DataSources>. I can't figure out what I'm doing wrong..

require 'rexml/document'
doc = REXML::Document.new
datasource = doc.add_element 'DataSources'
datasource.add_element( 'DataSource', {'Name' => 'LOCAL', 'Type' =>
"Cedara DbS P10", 'Default' => '',
'MaxLimit' => 500})
schema = datasource.add_element 'Schema'
schema.add_text "DbSP10Schema.xml"
connectionstring = datasource.add_element 'ConnectionString'
connectionstring.add_text "Provider=ISG OLE DB DbS Provider; Data
Source=localhost:3205"

doc.write

This is because you did not add nested elements to DataSource. My
output looks like this

irb(main):013:0* doc.write
<DataSources><DataSource MaxLimit='500' Name='LOCAL' Default=''
Type='Cedara DbS
P10'/><Schema>DbSP10Schema.xml</Schema><ConnectionString>Provider=ISG
OLE DB DbS Provider; Data
Source=localhost:3205</ConnectionString></DataSources>=> [<?xml ...
?>, <DataSources> ... </>]

This is because you probably confused DataSources and DataSource.
Your variable named "datasource" holds DataSources and so you add
Schema to that instead of to DataSource.

Kind regards

robert
Understood! Thank you!

--Aldric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top