XML parsing, ISO8859-1 & UTF-8

Hello,

I have to use the information in a webservice which look like this :

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">
&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
&lt;Name&gt;Test_Name&lt;/Name&gt;
</string>

The problem is the two different encoding formats...

I first used REXML, but the .elements[..] method returns nil

Would someone have a solution to get the XML tags and the information it
contain ?

Thank you

···

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

Since you're embedding XML in XML you need to parse twice. Btw. it
doesn't really make much sense to have a different encoding in the
nested XML because from XML's point of view the whole document is
encoded with UTF-8 and hence also the inner text needs to use that
encoding. If you want to use a different encoding you'll have to
encode the inner text yourself, probably as binary (e.g. BASE64).

Cheers

robert

···

On Wed, Sep 18, 2013 at 5:38 PM, tt rr <lists@ruby-forum.com> wrote:

Hello,

I have to use the information in a webservice which look like this :

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="Bing;
&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
&lt;Name&gt;Test_Name&lt;/Name&gt;
</string>

The problem is the two different encoding formats...

I first used REXML, but the .elements[..] method returns nil

Would someone have a solution to get the XML tags and the information it
contain ?

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/