From: daz Date: 2005-11-15T05:12:16+09:00 Subject: Re: REXML -> attributes with single/double quotes Stephan K�mper wrote: > Hi all, > > when I write a previously read XML using REXML, all attribute values are > single quoted. Unfortunately the application I'm feeding that XML to > (currently) can't cope with that. Throw it away :-) > > I tried to rad and understand the XML Standard, but couldn't find the > exact place where it says, that both single and double quoted strings > are allowed to delimit attribute values. > If this the right place? > > > [10] AttValue ::= '"' ([^<&"] | Reference)* '"' > | "'" ([^<&'] | Reference)* "'" > > > From: http://www.w3.org/TR/REC-xml/ > Section 2.3 "Common Syntactic Constructs" > > That seems to say that attributes are either delimited by single quotes > or by double quotes. http://www.w3.org/TR/REC-xml/#sec-notation "string" matches a literal string matching that given inside the double quotes. 'string' matches a literal string matching that given inside the single quotes. > > > > REXML::Attribute.class_eval( %q^ > > def to_string > > %Q[#@expanded_name="#{to_s().gsub(/"/, '"')}"] > > end > > ^ ) > > > > Is there a more elegant way to achieve this? > I'd be disappointed if there wasn't -- sorry no help there, atm. daz