REXML is a conformant XML processor for the Ruby programming language. REXML is included in the standard library of Ruby.
Questions tagged [rexml]
124 questions
0
votes
1 answer
Ruby REXML throws ParseException, but PHP xml parser works
I'm trying to call a web service from a PHP page via a Ruby script. The PHP script returns a string and itself calls another web service; I've tested the PHP script alone and it returns a single string. I'm trying to call this method via RPC using…

Wayne Molina
- 19,158
- 26
- 98
- 163
0
votes
2 answers
How would I construct a Hash from this scenario in Ruby?
Given I have the following code:
ENDPOINT = 'http://api.eventful.com'
API_KEY = 'PbFVZfjTXJQWrnJp'
def get_xml(url, options={})
compiled_url = "#{ENDPOINT}/rest#{url}" << "?app_key=#{API_KEY}&sort_order=popularity"
options.each { |k,…
user2005477
0
votes
1 answer
XPath does not return text in RoR
My code:
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new(response)
REXML::XPath.each(doc, "*//categoryName") { |element| puts element.text }
What I want this to return is the text element inside the tag... what it…

DaveyGravy
- 21
- 5
0
votes
2 answers
Xpath.each not working in rails
My code:
require 'rexml/document'
require 'xpath'
doc = REXML::Document.new(xml)
XPath.each(doc, "*/categoryName") { |element| puts element.text }
I am trying to take object xml where xml is a string of xml... and retrieve some text ie - I want…

DaveyGravy
- 21
- 5
0
votes
1 answer
REXML::Document.new can we give encode parameters on this line?
doc = REXML::Document.new file
My code is failing at this point whenever my xml file contains some special characters other than UTF-8 .
REXML::ParseException (#

Vinay
- 237
- 2
- 8
- 17
0
votes
1 answer
How do I return a value from inside a loop?
I am trying to read an XML file and store the structure into an array of objects. Here is my code:
class Bike
attr_accessor :id, :color, :name
def initialize(id, color, name)
@id = id
@color = color
@name = name
…

Karthick S
- 3,204
- 6
- 36
- 52
0
votes
1 answer
Preserving whitespace / line breaks with REXML
I'm using Ruby 1.9.3 and REXML to parse an XML document, make a few changes (additions/subtractions), then re-output the file. Within this file is a block that looks like this:
some.namespace.something1=somevalue1
…

Fopedush
- 2,036
- 4
- 20
- 22
0
votes
1 answer
REXML and encoding
Can anyone please explain this result for me?
#!/usr/bin/env ruby
# encoding: utf-8
require 'rexml/document'
doc = REXML::Document.new(DATA)
puts "doc: #{doc.encoding}"
REXML::XPath.each(doc, '//item') do |item|
puts " #{item}:…

Amadan
- 191,408
- 23
- 240
- 301
0
votes
1 answer
0
votes
1 answer
How do I control REXML formatting on added elements?
I am a adding a couple of simple elements to a bunch of XML files (plists). The existing XML element I am working on looks like this:
background
#FFFFFF
caret
#000000
…

Charles Roper
- 20,125
- 20
- 71
- 101
0
votes
2 answers
ruby rexml: parsing xml files cleanly
I have the following XML file:
SP_url_1
SP_url_2
I want to get all the URL elements'…

Emil Petkov
- 375
- 1
- 4
- 14
0
votes
1 answer
REXML: How to add the root element in a exiting but empty file?
I have an empty XML page I've called "users.xml". I'd like to be able to create all the content using REXML.
require "rexml/document"
include REXML # so that we don't have to prefix everything with REXML::...
xmlfile = File.new("users.xml")
doc =…

Richard77
- 20,343
- 46
- 150
- 252
0
votes
1 answer
rexml page.root.has_elements? says no elements
I tried to read the following file:
with the code below:
require 'rexml/document'
include REXML
str = File.read("../pages/prac.xml").gsub(/\s+/, " ")
page = REXML::Document.new(str)
print "no elements\n" if…

Karthick S
- 3,204
- 6
- 36
- 52
0
votes
1 answer
Rails 3.2 conflict between Comment model and REXML's Comment
I have a model called "Comment" in my Rails 3.2 app and it works in my application. However, I made a script, run by rails runner, which inserts data such as comments in my database and I get the following error…

R3v4n
- 739
- 6
- 11
-1
votes
1 answer
how to get my rexml/nokogiri script run faster
I have this ruby script that collects 46344 xml-links and then collects 16 elements-nodes in every xml file. The last part of the proccess is that it stores it in a CSV file. The problem that I have is that it takes to long. It takes more than 1-2…
user592638