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

Delete XML Tag

Former Member
0 Likes
506

In my program , I am reading am XML string and i want to delete all the occurences of the XML tag below:

<desc>

<text xmlns:xft-xliff="http://www.xfa.org/schema/xfa-xliff/1.0/" name="Schema Annotation" xft-xliff:id="N897">d3153e10ea5711dac5bb001279d7d2c2</text>

</desc>

I tried to write the below way but it doesn't work .

REPLACE ALL OCCURRENCES OF '<desc>

\<[[:alnum:]]+\> <desc>' IN cp_xml_string WITH ' 'IGNORING CASE.

Please provide any input.

Thanks,

Sri

1 REPLY 1
Read only

Lukas_Weigelt
Active Contributor
0 Likes
382

Hi,

If it's an xstring, you could try to convert it into a DOM...

CALL FUNCTION 'SDIXML_XML_TO_DOM'
    EXPORTING
      xml           = lv_serializied_stream
    IMPORTING
      document      = lo_if_xml_document
    EXCEPTIONS
      invalid_input = 1
      OTHERS        = 2.

...and then navigate down where required and work with "IF_IXML_NODEREMOVE_NODE" and "IF_IXML_NODEREMOVE_CHILD". I'm not sure whether you can use this, because I'm not aware of the dynamics and complexity of your XML stream, but this sure would be a possibility in general.

regards, Lukas