Libxml and umlauts

Hi,

i have try my first steps with libxml.

The first problem i need the german umlauts (äöß…).
The second, i will get only one element like
"werte.elements["//INVOICE_NO"].text" in REXML

Here my files:
bill.xml

?xml version=“1.0” encoding=“ISO-8859-1”?>

<PRODUCT_NAME>Anschluß</PRODUCT_NAME>

#!/usr/bin/ruby
require “xml/libxml”

xp = XML::Parser.new()
xd = XML::Document.file(’./bill.xml’)
xd.encoding=‘ISO-8859-1’

werte = xd.find(’/BILLITEM/PRODUCT_NAME’)
werte.each do |n|
puts n # Anschluà not ß
end

Manfred Hansen

Hi,

my first solution.

#!/usr/bin/ruby
require “xml/libxml”
require “iconv”

xd = XML::Document.file(‘./bill.xml’)
icon = Iconv.new(‘ISO-8859-1’,‘UTF-8’)
puts icon.iconv(xd.find(‘/BILLITEM/PRODUCT_NAME’).to_a[0].to_s)

Maybe someone find a better solution?

Manfred Hansen

···

Hi,

i have try my first steps with libxml.

The first problem i need the german umlauts (äöß…).
The second, i will get only one element like
“werte.elements[”//INVOICE_NO"].text" in REXML

Here my files:
bill.xml

<?xml version="1.0" encoding="ISO-8859-1"?> Anschluß

#!/usr/bin/ruby
require “xml/libxml”

xp = XML::Parser.new()
xd = XML::Document.file(‘./bill.xml’)
xd.encoding=‘ISO-8859-1’

werte = xd.find(‘/BILLITEM/PRODUCT_NAME’)
werte.each do |n|
puts n # Anschluà not ß
end

Manfred Hansen