2005-09-23

Parsing XML (Releases 4.6C and up)

Finally I have found the way! Maybe it also works for Releases prior to 4.6C - give it a try.
  1. Copy Report BCCIIXMLT1
  2. (you can change the way of filling internal table xml_table if necessary)
  3. you don't need the part between
    *-- render the DOM back into an output stream/internal table
    and
    *-- print the whole DOM tree as a list...
    Comment it out or simply delete it
  4. Rename form print_node to your liking e.g. process_node
  5. In your new form you need three extra variables:
    data: attribs type ref to IF_IXML_NAMED_NODE_MAP,
          attrib_node type ref to IF_IXML_NODE,
          attrib_value type string.
  6. After the lines:
    when if_ixml_node=>co_node_element.
      string = pNode->get_name( ).
    Insert:
    attribs = pNode->get_attributes( ).
    clear attrib_value.
    case string.
      when ''. "put your XML tag name here
        attrib_node = attribs->get_named_item(name = '' ). "put your XML attribute name here
        attrib_value = attrib_node->get_value( ).
  7. replace the write statements to whatever you need

Voila! That's it! It did work for me. (In my case the part of the program:

when if_ixml_node=>co_node_text.
has been never reached.)

No comments:

Post a Comment