Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do handle control flow better and nil objects in ruby
    primarykey
    data
    text
    <p>I have this script that is a part of a bigger one. I have tree diffrent XML files that looks a litle diffrent from each other and I need some type of control structure to handle nil-object and xpath expressions better</p> <p>The script that I have right now, outputs nil objects: </p> <pre><code>require 'open-uri' require 'rexml/document' include REXML @urls = Array.new() @urls &lt;&lt; "http://testnavet.skolverket.se/SusaNavExport/EmilObjectExporter?id=186956355&amp;amp;strId=info.uh.kau.KTADY1&amp;amp;EMILVersion=1.1" @urls &lt;&lt; "http://testnavet.skolverket.se/SusaNavExport/EmilObjectExporter?id=184594606&amp;amp;strId=info.uh.gu.GS5&amp;amp;EMILVersion=1.1" @urls &lt;&lt; "http://testnavet.skolverket.se/SusaNavExport/EmilObjectExporter?id=185978100&amp;amp;strId=info.uh.su.ARO720&amp;amp;EMILVersion=1.1" @urls.each do |url| doc = REXML::Document.new(open(url).read) doc.elements.each("/educationInfo/extensionInfo/nya:textualDescription/nya:textualDescriptionPhrase | /ns:educationInfo/ns:extensionInfo/gu:guInfoExtensions/gu:guSubject/gu:descriptions/gu:description | //*[name()='ct:text']"){ |e| m = e.text m.gsub!(/&lt;.+?&gt;/, "") puts "Description: " + m puts "" } end </code></pre> <p>OUTPUT:</p> <blockquote> <p>Description: bestrykning, kalandrering, tryckning, kemiteknik</p> <p>Description: Vill du jobba med internationella och globala frågor med... Description: The study of globalisation is becoming ever more important for our understanding of today´s world and the School of Global Studies is a unique environment for research.</p> <p>Description: </p> <p>Description: </p> <p>Description: Kursen behandlar identifieringen och beskrivningen av sjukliga förändringar i mänskliga skelett. Kursen ger en ämneshistorisk bakgrund och skelettförändringars förhållanden till moderna kliniska data diskuteras.</p> </blockquote>
    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.
    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