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

How to get node/element value from XPATH

former_member189354
Contributor
0 Likes
847

Hi,

I built DOM tree is there any way to have element values using XPATH. I am maintaing XPATH's in one of Ztables. Appreciate response.

Thanks,

Rao.Mallikarjuna

3 REPLIES 3
Read only

Former Member
0 Likes
604

hi,

the following link can be very useful for the same.

http://www.w3schools.com/XPath/xpath_syntax.asp

hope it helps

Read only

uwe_schieferstein
Active Contributor
0 Likes
604

Hello Rao

It would be helpful if you had described how you build your DOM tree.

However, on SAP-XI I use the following ABAP class mapping to modify a DOM tree (insert file generation number (FLGN) into an EDI TRADACOM93 invoice message):


METHOD MAP_FLGN.
* define local data
  DATA: lo_node         TYPE REF TO if_ixml_node,
        lo_incode       TYPE REF TO if_ixml_node_collection,
        lo_child        TYPE REF TO if_ixml_node,
*
        ld_name         TYPE string,
        ld_value        TYPE string,
        ld_rc           TYPE i,
        ld_error_code   type MPG_ERRCODE,
        ld_msg          TYPE string.  " bapi_msg.

  DATA: ld_param_name   TYPE mpp_paramname,
        ld_param_value  TYPE string,
        ls_record       TYPE mpp_dynamic.

...
* NOTE: Structure of S_FIL segment (1st child = FLGN)
**  <S_FIL>
**    <FLGN>1133</FLGN>
**    <FLVN>1</FLVN>
**    <FLDT>080617</FLDT>
**    <FLID />
**  </S_FIL>

" NOTE: MO_DOCUMENT is TYPE REF TO if_ixml_document

* Get node collection of segment S_FIL (TRADACOM message)
  CLEAR: lo_incode,
         lo_node,
         lo_child.
  lo_incode  = mo_document->get_elements_by_tag_name( mc_segedi_s_fil ).

  ASSERT ID zedi
    FIELDS 'lo_incode'
    CONDITION ( lo_incode IS BOUND ).


  lo_node  = lo_incode->get_item( index = if_ixml_node=>co_node_xxx ).
  lo_child = lo_node->get_first_child( ).
  ld_name  = lo_child->get_name( ).

  ASSERT ID zedi
    FIELDS ld_name
    CONDITION ( ld_name = mc_flgn ).


* Set new File Generation Number (FLGN) into XML stream
  CALL METHOD lo_child->set_value
    EXPORTING
      value = ld_value
    RECEIVING
      rval  = ld_rc.
  IF ( ld_rc NE 0 ).
...

Regards

Uwe

Read only

former_member189354
Contributor
0 Likes
604

We can use SAP's Proxy Framework intenal classes to do this. Issue is resolved.

Thanks & Regards,

Rao.Mallikarjuna