Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing xmlSimple.xmlIn(file) With Ruby
    primarykey
    data
    text
    <p>I am having trouble getting xmlSimple to run correctly in my .rb file. I am using <code>xmlSimple.xmlIn(filename);</code>, however, it seems there is an error with finding the correct file. I have moved the file to the bin and the file exists, meaning, <code>filename.exists? = true</code>. Any ideas on the possible error source? Thanks!</p> <p>-Edit- Let me add this information; I am very new to Ruby and there is a good chance my method or syntax is completely wrong, here is my code in the .rb file:</p> <pre><code>require 'xmlsimple' file_name = 'xmldatatest.xml' paragraph_str = 0 file = File.open(file_name) # takes XML Data and creates a file of the data File.open(file_name, "w+") do |f| # open file for update lines = f.readlines # read into array of lines lines.each do |it| # modify lines it.gsub!(/\n/, '') it.gsub!('&lt;p&gt;', '') it.gsub!('&lt;/p&gt;', '') it.gsub!('\"Paragraph.\"', 'Paragraph') if ((it.include? ('Paragraph')) == 1) paragraph_str += 1 end while paragraph_str &gt; 0 do initial_value = paragraph_str if ((paragraph_str == initial_value)) it.gsub!(/Paragraph/, '&lt;p&gt;') paragraph_str -= 1 else it.gsub!(/Paragraph/, '&lt;/p&gt;&lt;p&gt;') paragraph_str -= 1 end end f.print lines # write out modified lines end end File.open(file_name, 'a') {|f| f.puts "&lt;/p&gt;" } ref = XmlSimple.xml_in(file_name) </code></pre> <p>The purpose of the program is to strip all escape characters from the original XML file and then replace each "Paragraph#" node within a <code>&lt;p&gt;</code> and <code>&lt;/p&gt;</code> tag. After which, the file would be parsed using <code>XmlSimple.Xml_in(filename)</code>. Any suggestions or corrections are more than appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload