Excel to xml

i have done excel to xml conversion like this but the problem is…if i
rename the “d:\database\terget.txt” to “d:\database\terget.xml” then the
file is not opening as a xml file & " The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and
then click the Refresh button, or try again later.


Invalid at the top level of the document. Error processing resource
‘file:///D:/database/terget.xml’. Line 1, Position 1

  • 10043-35-3 "
    ^
    this error messege is generated

but if i use this as text file it is opening in internet explorer.

& another thing is that if i want to use
1)dynamic path to select the source excel file… what should i do?

2)& the features of xml in this file that is the expanding & Collapseing
features by ‘-’ & ‘+’ sign i want to add, but how?
its very urgent realy
thanx

require ‘parseexcel’
require ‘win32ole’
require ‘roo’
workbook = Spreadsheet::ParseExcel.parse(‘d:\source.xls’)
worksheet = workbook.worksheet(0)
puts
@C = 0
@r = 0
@header = []
@fn=[]
skip = 0
worksheet.each(skip){|row|
first_cell = row
File.open(‘d:\test.txt’,‘a’) do |f|
if @r < 1
@C = first_cell.length
for l in 0…@C
@header[l] = first_cell[l].to_s(‘latin1’)
end
end
@r = @r +1

end
}

skip =1
@cnt=0
worksheet.each(skip) { |row|
File.open(‘d:\database\terget.xml’,‘a’) do |file|

         first_cell=row
       for l in [email protected]
           if first_cell[l] !=nil
              str = first_cell[l].to_s('latin1')
          else
           str = ' '
           end
           file.puts "- <" + @header[l] + ">" + str + "</" + 

@header[l]+ “>”
file.puts
end
end
@cnt= @cnt+1
}

On 11 Apr 2008, at 10:53, Sumanta D. wrote:

2)& the features of xml in this file that is the expanding &
Collapseing
features by ‘-’ & ‘+’ sign i want to add, but how?
its very urgent realy
thanx

Umm that’s not an xml thing. The program displaying the xml may choose
to do that, but that’s absolutely not somthing that should be in the
xml itself. (and it looks like that’s what’s causing your parse error)

Fred

but can u help me on that…
if u can help me by submitting code in reply that will be realy helpfull
for me
its urgent please…

On 11 Apr 2008, at 11:37, Sumanta D. wrote:

but can u help me on that…
if u can help me by submitting code in reply that will be realy
helpfull
for me
its urgent please…

There is absolutely nothing that you can put in an xml file that will
make the elements be collapsable. xml just describes some data, it
doesn’t care about how it’s displayed. The program displaying the data
may choose to do nice things such as some form of syntax highlighting.
If you stick a bare xml document into firefox for example, you’ll get
your collapsable nodes, because that’s just how firefox likes to
display xml. If you need more then you could always right an xsl
stylesheet that transforms the xml into an html document with all the
GUI niceties that you want.

Fred

On 11 Apr 2008, at 12:04, Sumanta D. wrote:

stylesheet that transforms the xml into an html document with all the
that will be really helpfuul to me
Which u want to say above i know that…but i can’t reach the goal
thats
why i am submitting the code,asked for solution…
can u help me(coding+advice) to solve it???

As far as the xml generation goes, you should probably look a
something like builder (as it is you could very easily be generating
invalid xml if the cells contain any of the forbidden characters.

Fred

There is absolutely nothing that you can put in an xml file that will
make the elements be collapsable. xml just describes some data, it
doesn’t care about how it’s displayed. The program displaying the data
may choose to do nice things such as some form of syntax highlighting.
If you stick a bare xml document into firefox for example, you’ll get
your collapsable nodes, because that’s just how firefox likes to
display xml. If you need more then you could always right an xsl
stylesheet that transforms the xml into an html document with all the
GUI niceties that you want.

but in my project have to read excel file& i have to generate xml for
each row individualy…& all the xml should in a common file as i want
to do there…
now can u help me by submitting some code to me??
that will be really helpfuul to me
Which u want to say above i know that…but i can’t reach the goal thats
why i am submitting the code,asked for solution…
can u help me(coding+advice) to solve it???

plz provide some code/example

On 11 Apr 2008, at 12:28, Sumanta D. wrote:

plz provide some code/example

http://builder.rubyforge.org/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs