2014 Nov 01 8:09 AM
Dear friends,
I have a problem while converting xml file into internal table (de-serialization) using simple transformation.
there is a tag like <tag> </tag> and I am using condition to check whether tag consist data or not.
because of the space value in the tag I am getting an exception 'CX_ST_COND_CHECK_FAIL' during the condition check.
before deserialization, i am removing empty tags from the xml by using below statement.
REPLACE ALL OCCURRENCES OF REGEX '<\w+/>' IN l_string WITH ''.
but because the tag has the space value it is not getting removed from the XML.
and i am using below code to check is there any tag with empty value. at this condition, because of space value
i am getting the exception 'CX_ST_COND_CHECK_FAIL'.
<tt:cond check="DENIAL_CODE!=''">
<DenialCode tt:value-ref="DENIAL_CODE"/>
</tt:cond>
please advise on this.
Regards,
Rajesh
2014 Nov 02 10:38 AM
If xml is well formed, below regular expression can be used.
If xml is ill formed, the transformation will fail anyways.
DATA lv_str TYPE string VALUE '<tag1><tag2><tag> </tag><tag>asdf<tag><tag> </tag></tag2><tag1>'.
REPLACE ALL OCCURRENCES OF REGEX '<\w+> </\w+>' IN lv_str WITH ''.
WRITE lv_str.
If xml is well formed, below regular expression can be used.
If xml is ill formed, the transformation will fail anyways.
DATA lv_str TYPE string VALUE '<tag1><tag2><tag> </tag><tag>asdf<tag><tag> </tag></tag2><tag1>'.
REPLACE ALL OCCURRENCES OF REGEX '<\w+> </\w+>' IN lv_str WITH ''.
WRITE lv_str.
2014 Nov 02 10:38 AM
If xml is well formed, below regular expression can be used.
If xml is ill formed, the transformation will fail anyways.
DATA lv_str TYPE string VALUE '<tag1><tag2><tag> </tag><tag>asdf<tag><tag> </tag></tag2><tag1>'.
REPLACE ALL OCCURRENCES OF REGEX '<\w+> </\w+>' IN lv_str WITH ''.
WRITE lv_str.
2014 Nov 02 11:38 AM
Thank you Manish,
it seems you code is working fine, but are you sure that it will not delete any other tags.
let me know your comments.
Regards,
Rajesh A.
2014 Nov 02 11:45 AM
It should work fine for well formed xml. Potentially it will also delete occurrences like <tag> </anothertag> but that is not expected in real xml.
2014 Nov 11 7:18 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |