Log in
updated 11:29 AM UTC, May 4, 2016

How to read an XML file from the internet and print selected values

  • Written by Madhu V Rao
  • Published in Ruby

How to read an XML file from the Internet and print selected values

This program is written using nokogiri xml parser. If you havent already installed Nokogiri in your system. Please download it in nokogiri.org.

It reads an http XML file and prints only <fullName> node value from it. 


# To change this template, choose Tools | Templates
# and open the template in the editor.

require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'net/http'

class ReadXMLFileFromNet
  def print_all_names
    @urls = Array.[]()
    input = Nokogiri::XML(open("http://ictforu.com/images/xml/matches.xml"))
    input.xpath('//fullname').each { |node|  @urls<<node.content }

    @urls.each do |append|
      puts append

objectFile = ReadXMLFileFromNet.new

Powered by Bullraider.com
Follow Us on Twitter
Find Us on Facebook
Follow Us on Google
Follow Us on Pinterest