Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

XML TAG

Former Member
0 Likes
1,280

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

5 REPLIES 5
Read only

Former Member
0 Likes
731

you can do it by writing Simple transformation .

Read only

Former Member
0 Likes
731

use CALL TRANSFORMATION ID.

press F1 for help... or please search in SDN. we already have posts on this.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
731

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

Read only

Former Member
0 Likes
731

Thanks a lot.

Soufiene

Read only

Former Member
0 Likes
731

Thanks