MUNDOSAP

Regresar   MUNDOSAP > DESARROLLO > Programación ABAP IV
Nombre de Usuario
Contraseña
Home Descargas Registrar FAQ Miembros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos




 
Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Viejo 03/04/07, 15:05:47
Jamez Betancourt Jamez Betancourt is offline
Junior Member
 
Fecha de Ingreso: jul 2006
Mensajes: 6
XML en formato UTF-8

Necesito grabar un xml en formato utf-8 pero no veo el caracter especial al inicio del archivo que indica que es utf-8 como cuando se hace con el notepad, es correcto? de antemano gracias por la ayuda
Codigo ejemplo:
REPORT YBORRAME3 .
TYPE-POOLS TRUXS.
data: nom_archivo(50) TYPE c,
g_arch_enviar(128) TYPE c.
* data: L_RESULT TYPE ETXML_LINE_STR.
CONSTANTS: ENCODING(5) VALUE 'UTF-8'.

DATA: L_RIF_IXML TYPE REF TO IF_IXML,
l_rif_streamfactory type ref to if_ixml_stream_factory,
l_rif_parser type ref to if_ixml_parser,
l_rif_istream type ref to if_ixml_istream,
l_rif_document type ref to if_ixml_document,
l_rif_node type ref to if_ixml_node,
l_var_xmldata type string,
l_var_xmldata2 type string,
l_var_cstr type xstring,
l_rif_ostream type ref to if_ixml_ostream,
l_rif_encoding type ref to if_ixml_encoding,
l_rif_renderer_cstr type ref to if_ixml_renderer,
l_var_ret type i.

data: l_var_dsn type string.

l_var_xmldata = '<?xml version="1.0" encoding="utf-8"?><C dr="ñ" "></C>'
.
nom_archivo = 'utf8.xml'.

* Text-001 Ruta de unix a donde enviara el Archivo.
CONCATENATE '/tmp/' nom_archivo INTO g_arch_enviar.

CLASS cl_ixml DEFINITION LOAD.
* Create cebtral fatory object
l_rif_ixml = cl_ixml=>create( ).

* Create factory object for data streams
l_rif_streamfactory = l_rif_ixml->create_stream_factory( ).

* Create object for input stream
l_rif_istream = l_rif_streamfactory->create_istream_string( string =
l_var_xmldata ).

* Create document
l_rif_document = l_rif_ixml->create_document( ).

* Create parser
l_rif_parser = l_rif_ixml->create_parser( document = l_rif_document
stream_factory = l_rif_streamfactory
istream = l_rif_istream ).

* create dom tree by parsing
if l_rif_parser->parse( ) <> 0.
data: j(2).
j = '9'.
* do exception handling here
* return.
endif.

*create output objetct
l_rif_ostream =
l_rif_streamfactory->create_ostream_xstring( string = l_var_cstr ).

*create file in utf-8 code
l_rif_encoding = l_rif_ixml->create_encoding( character_set = 'UTF-8'
byte_order = 0 ).

CALL METHOD l_rif_ostream->SET_ENCODING
EXPORTING
ENCODING = l_rif_encoding.

* create renderer objetct
l_rif_renderer_cstr =
l_rif_ixml->create_renderer( document = l_rif_document
ostream = l_rif_ostream ).
* use renderer
l_var_ret = l_rif_renderer_cstr->render( ).

* Close output stream
*call method istream->close( )
call method l_rif_ostream->close( ).

*l_rif_ostream->close( ).

*Writing string to file

open dataset g_arch_enviar FOR OUTPUT in binary mode.
transfer l_var_cstr to g_arch_enviar.
close dataset g_arch_enviar.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Reglas de Mensajes
no puedes crear nuevos temas
no puedes responder temas
no puedes adjuntar archivos
no puedes editar tus mensajes

El código vB está On
Las caritas están On
Código [IMG] está On
Código HTML está Off
Saltar a Foro


Husos Horarios son GMT. La hora en este momento es 20:27:48.


www.mundosap.com 2006 - Spain
software crm, crm on demand, software call center, crm act, crm solutions, crm gratis, crm web