PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > REXML formatting due to changes from 1.8.4 to 1.8.6
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
REXML formatting due to changes from 1.8.4 to 1.8.6

Réponse
 
LinkBack Outils de la discussion
Vieux 12/03/2008, 22h17   #1
Wes Gamble
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut REXML formatting due to changes from 1.8.4 to 1.8.6

Apparently there was an overhaul of REXML formatting between Ruby 1.8.4
and 1.8.6.

The new formatting of XML that I'm generating with REXML is not being
consumed correctly by the consumer anymore.

Elements containing values were written out like this in 1.8.4:

<concurrency>1008</concurrency>

Now they are written out like this:

<concurrency>
1008
</concurrency>

How can I get the old behavior back? I see some mention of formatters -
so any hints on a good reference for how to use the formatters would be
welcome.

Thanks,
Wes
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 12/03/2008, 22h30   #2
Wes Gamble
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: REXML formatting due to changes from 1.8.4 to 1.8.6

(I see now there's been a lot of discussion about this ;])

SOLUTION:

I changed the following method (where @document is a XML doc. created by
REXML):

def write()
File.open("#{@file_path}", 'w') do |f|
@document.write(f, 0)
end
end

to:

def write()
formatter = REXML::Formatters:efault.new
File.open("#{@file_path}", 'w') do |f|
formatter.write(@document, f)
end
end

after making sure to require 'rexml/formatters/default' and I'm back in
business.

I can imagine that a lot of people have run into this, and given that
we're probably generating XML to communicate information to another
system, I'm sure it has spawned some consternation. Backwards
compatibility can be a tricky thing .

Hope this s,
Wes


--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h25.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07279 seconds with 10 queries