MUNDOSAP

MUNDOSAP (foro/index.php)
-   Programación ABAP IV (foro/forumdisplay.php?f=4)
-   -   Crear xml (foro/showthread.php?t=72018)

anaidosa 08/07/14 14:06:58

Crear xml
 
Buen dia.

Espero me puedan ayudar.

Estoy creando un XML con la interface IF_IXML y uso el metodo CREATE_DOCUMENT y ya lo genero mas que en el ejemplo que me mandan debe de quedar de la siguiente forma el nodo

<paisOrigen xmlns="http://tempuri.org/">
<string>pais</string>
</paisOrigen>

Pero a mi me queda de la siguiente forma

<paisOrigen xmlns="http://tempuri.org/">
<string>pais</string>
</paisOrigen xmlns="http://tempuri.org/">

por lo tento me manda un error el codigo lo tengo de la siguiente manera

DATA: doc1 TYPE REF TO if_ixml_element,
DATA: lo_document TYPE REF TO if_ixml_document.

doc1 = lo_document->create_simple_element(
name = 'paisOrigen xmlns="http://tempuri.org/"'
parent = eje ).
lo_document->create_simple_element( name = 'string'
parent = doc1
value = 'pais' ).

Espero me puedan ayudar

Saludos

cmacvicar 09/07/14 22:07:03

Ejemplo de lo Necesitado


DATA: ixml TYPE REF TO if_ixml,
document TYPE REF TO if_ixml_document,
parent TYPE REF TO if_ixml_node,
element TYPE REF TO if_ixml_element,
cdata TYPE REF TO if_ixml_cdata_section.

ixml = cl_ixml=>create( ).
document = ixml->create_document( ).

* Crea Nivel 1 de XML (Documento)
element = document->create_element( name = 'paisOrigen' ).
document->append_child( new_child = element ). " Nombre Documento
parent = element.

* Crea Nivel 2 de XML
*element = document->create_element( name = 'NIVEL_2' ).
*parent->append_child( new_child = element ). " Sub nivel del Doc.
*parent = element.

* Ingresa Atributo del Nodo
element->set_attribute( name = 'xmlns' value = 'http://tempuri.org/' ).

* Ingresar Nombre del Nodo
element = document->create_element( name = 'string' ).

* Ingresar Valor del Nodo
cdata = document->create_cdata_section( `pais` ).

* Crear Registro en Documento
element->append_child( new_child = cdata ).

* Cierra Documento
parent->append_child( new_child = element ).

* Mostrar XML por Pantalla
CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
EXPORTING
document = document
EXCEPTIONS
OTHERS = 01.


Husos Horarios son GMT. La hora en este momento es 23:04:49.

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