Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You still haven't given enough details about what you actually want for me to give you a good answer, but you've given just enough to get <em>an</em> answer. :p</p> <p>The following shows how to load your XML file into a Nokogiri document, create a Haml template (which would be part of your Rails view; if you're using Erb or some other template system, say so) that runs through a list of <code>sdnEntry</code> and performs a completely naive huge dump of all the XML. If you want specific nodes, then you should have said so.</p> <pre class="lang-ruby prettyprint-override"><code>require 'nokogiri' require 'haml' # Haml helper to create a naive hierarchy of dl/dt/dd for any xml node def xml_to_dl(node) haml_tag('dl') do node.elements.each do |n| haml_tag('dt',n.name) if n.elements.empty? haml_tag('dd',n.text) else haml_tag('dd'){ xml_to_dl(n) } end end end end # This would be your page.haml view template = Haml::Engine.new &lt;&lt;'ENDHAML' %section#sdnList %h1#sdnList SDN List Awesomeness - if @sdns.empty? %p.error No entries found. :( - else %p Here are some exciting sdnEntries. Check em out! - @sdns.each do |sdn| %h2.name #{sdn.at('lastName').text}, #{sdn.at('firstName').text} - xml_to_dl(sdn) ENDHAML # This would be in your controller doc = Nokogiri.XML(IO.read('sdn.xml')) doc.remove_namespaces! # Make life easier @sdns = doc.xpath('/sdnList/sdnEntry[firstName][position() &lt; 2]') # This is taken care of by rails puts template.render(self) </code></pre> <p>And here's the output that particular template would create:</p> <pre class="lang-html prettyprint-override"><code>&lt;section id='sdnList'&gt; &lt;h1 id='sdnList'&gt;SDN List Awesomeness&lt;/h1&gt; &lt;p&gt;Here are some exciting sdnEntries. Check em out!&lt;/p&gt; &lt;h2 class='name'&gt;GONZALEZ BOHORQUEZ, Guillermo&lt;/h2&gt; &lt;dl&gt; &lt;dt&gt;uid&lt;/dt&gt; &lt;dd&gt;11764&lt;/dd&gt; &lt;dt&gt;firstName&lt;/dt&gt; &lt;dd&gt;Guillermo&lt;/dd&gt; &lt;dt&gt;lastName&lt;/dt&gt; &lt;dd&gt;GONZALEZ BOHORQUEZ&lt;/dd&gt; &lt;dt&gt;sdnType&lt;/dt&gt; &lt;dd&gt;Individual&lt;/dd&gt; &lt;dt&gt;programList&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;program&lt;/dt&gt; &lt;dd&gt;SDNT&lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;dt&gt;idList&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;id&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;uid&lt;/dt&gt; &lt;dd&gt;6139&lt;/dd&gt; &lt;dt&gt;idType&lt;/dt&gt; &lt;dd&gt;Cedula No.&lt;/dd&gt; &lt;dt&gt;idNumber&lt;/dt&gt; &lt;dd&gt;6185654&lt;/dd&gt; &lt;dt&gt;idCountry&lt;/dt&gt; &lt;dd&gt;Colombia&lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;dt&gt;id&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;uid&lt;/dt&gt; &lt;dd&gt;6140&lt;/dd&gt; &lt;dt&gt;idType&lt;/dt&gt; &lt;dd&gt;Passport&lt;/dd&gt; &lt;dt&gt;idNumber&lt;/dt&gt; &lt;dd&gt;AJ772175&lt;/dd&gt; &lt;dt&gt;idCountry&lt;/dt&gt; &lt;dd&gt;Colombia&lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;dt&gt;addressList&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;address&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;uid&lt;/dt&gt; &lt;dd&gt;17790&lt;/dd&gt; &lt;dt&gt;address1&lt;/dt&gt; &lt;dd&gt;c/o UNIVISA S.A.&lt;/dd&gt; &lt;dt&gt;city&lt;/dt&gt; &lt;dd&gt;Cali&lt;/dd&gt; &lt;dt&gt;country&lt;/dt&gt; &lt;dd&gt;Colombia&lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;dt&gt;dateOfBirthList&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;dateOfBirthItem&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;uid&lt;/dt&gt; &lt;dd&gt;7272&lt;/dd&gt; &lt;dt&gt;dateOfBirth&lt;/dt&gt; &lt;dd&gt;20 Dec 1944&lt;/dd&gt; &lt;dt&gt;mainEntry&lt;/dt&gt; &lt;dd&gt;true&lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;dt&gt;placeOfBirthList&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;placeOfBirthItem&lt;/dt&gt; &lt;dd&gt; &lt;dl&gt; &lt;dt&gt;uid&lt;/dt&gt; &lt;dd&gt;7273&lt;/dd&gt; &lt;dt&gt;placeOfBirth&lt;/dt&gt; &lt;dd&gt;Buga, Valle, Colombia&lt;/dd&gt; &lt;dt&gt;mainEntry&lt;/dt&gt; &lt;dd&gt;true&lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;/dl&gt; &lt;/dd&gt; &lt;/dl&gt; &lt;/section&gt; </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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