Hi.
I'm doing the following parsing of an XML message
istream = streamfactory->create_istream_xstring( source ).
idocument = ixmlfactory->create_document( ).
iparser = ixmlfactory->create_parser(
stream_factory = streamfactory
istream = istream
document = idocument ).
iparser->parse( ).
CHECK iparser->is_dom_generating( ) EQ 'X'.
i_node ?= idocument.
i_iterator = i_node->create_iterator( ).
i_node = i_iterator->get_next( ).
WHILE NOT i_node IS INITIAL.
CASE i_node->get_type( ).
WHEN if_ixml_node=>co_node_element.
lv_name = i_node->get_name( ).
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
lv_fval = i_node->get_value( ).
IF lv_name EQ 'Attribute1'.
lv_attribute1 = lv_fval.
ELSEIF lv_name EQ 'Attribute2'.
lv_attribute2 = lv_fval.
ENDIF.
ENDCASE.
* advance to next node
i_node = i_iterator->get_next( ).
ENDWHILE.
This is what i've been doing with an XML without any attributes.
Now I have a an XML message looking like the following.
<header attribute1="value1" attribute2="value2" attribute3="value3" attribute4="value4" namespace> . . . Other segments comming here. not going to read any of them. . . . </header>
How would the ABAP code look to do what i'm looking for?
Read attribute2 and attribute3 and save the value2 and valu3 in 2 local variables.
BR
Kalle