‎2009 Dec 03 2:25 PM
Hi Guru,
I have a variable contain XML code
w_result = "
The value could be true or false .
Is there a fonction , i can read the value ?
Thanks a lot
Soufiène
‎2009 Dec 03 2:33 PM
‎2009 Dec 03 3:04 PM
use CALL TRANSFORMATION ID.
press F1 for help... or please search in SDN. we already have posts on this.
‎2009 Dec 03 3:38 PM
Hello Soufiène,
You can make use of the class CL_XML_DOCUMENT to read the value in the XML tags:
DATA: v_str TYPE string.
v_str = '<boolean xmlns="http://www.webservice.net">true</boolean>'.
DATA:
lcl_xml_doc TYPE REF TO cl_xml_document,
v_subrc TYPE sysubrc,
v_node TYPE REF TO if_ixml_node,
v_iterator TYPE REF TO if_ixml_node_iterator,
v_node_value TYPE string,
v_seqnc TYPE i.
* Create an instance of the class CL_XML_DOCUMENT
CREATE OBJECT lcl_xml_doc.
* Send XML to method parse_string from class cl_xml_document
v_subrc = lcl_xml_doc->parse_string( v_str ).
* Get the instance of the XML document
v_node = lcl_xml_doc->m_document.
CHECK NOT v_node IS INITIAL.
* Get the instance of the XML iterator
v_iterator = v_node->create_iterator( ).
* Get the next XML Node
v_node = v_iterator->get_next( ).
CLEAR v_seqnc.
WHILE NOT v_node IS INITIAL.
CASE v_node->get_type( ).
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section. "Node Text
v_node_value = v_node->get_value( ).
ENDCASE.
v_node = v_iterator->get_next( ).
ENDWHILE.
WRITE: v_node_value.Hope this helps.
BR,
Suhas
‎2009 Dec 03 6:33 PM
‎2009 Dec 03 6:57 PM