‎2006 Jun 07 9:06 PM
My program processes an xml data stored in CRM.
The program extracts the XML data as a string. I need to be able to access the data contained within a particular node.
The node <result> contains my data. I need to extract these values to do subsequent data table lookups.
Any assistance in gaining access to the result node values is appreciated.
An example of the file is shown below:
<?xml version="1.0" encoding="utf-8"?>
<survey xmlns:abapsurvey="http://www.sap.com/abapsurvey" xmlns:bee="http://www.sap.com/survey/bee" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:htmlb="http://www.sap.com/survey/htmlb" xmlns:out="http://www.w3.org/1999/XSL/Output" xmlns:svy="http://www.sap.com/survey/svy" xmlns:tmp="http://www.sap.com/survey/tmp" xmlns:values="http://www.w3.org/1999/XSL/TransformValues" xmlns:wff="http://www.mysap.com/wff/2001">
<ratingfactor>
<id_5067ea774ce37c4a998c56c296ef383e>0 </id_5067ea774ce37c4a998c56c296ef383e>
<q1>1 </q1>
<id_77cdd93138447b4b993442c2918b8bdb>0 </id_77cdd93138447b4b993442c2918b8bdb>
<id_37721faa404c814d9bc265b4f19887f0>0 </id_37721faa404c814d9bc265b4f19887f0>
<id_00ec9ccaf7f98542995c5b97261c90d1>0 </id_00ec9ccaf7f98542995c5b97261c90d1>
<id_74592f01f5cc2440a87fedda3754db8e>0 </id_74592f01f5cc2440a87fedda3754db8e>
</ratingfactor>
<result>
<id_5067ea774ce37c4a998c56c296ef383e>
<id_3887d603f663d644a03b8212f3af24e7>id_eb6cae9b1688f84babeaae6c2aa53796</id_3887d603f663d644a03b8212f3af24e7>
</id_5067ea774ce37c4a998c56c296ef383e>
<q1>
<a1>id_1f84102b913e3344a38cc166a9933452</a1>
</q1>
<id_77cdd93138447b4b993442c2918b8bdb>
<id_275bf37ff1a68f4c88aaf7d4fa6cd4dc>id_a655b90477634640955428143e4a6f66</id_275bf37ff1a68f4c88aaf7d4fa6cd4dc>
</id_77cdd93138447b4b993442c2918b8bdb>
<id_37721faa404c814d9bc265b4f19887f0>
<id_4915c8ad1dcf2740ac545d3ffd2a0af6>id_65d7c9277da37648b6600de52e2a095e</id_4915c8ad1dcf2740ac545d3ffd2a0af6>
</id_37721faa404c814d9bc265b4f19887f0>
<id_00ec9ccaf7f98542995c5b97261c90d1>
<id_2ef55b647e558a4eba40e8f78d15818d>id_46aabd5305894649b9d28f15c0e439b7</id_2ef55b647e558a4eba40e8f78d15818d>
</id_00ec9ccaf7f98542995c5b97261c90d1>
<id_74592f01f5cc2440a87fedda3754db8e>
<id_6182ead1dd8fe74abe9feccb316a86d3>This is my additional info for the customer.
</id_74592f01f5cc2440a87fedda3754db8e>
</result>
</survey>
‎2006 Jun 07 9:18 PM
I hope I understood you correctly. This program finds the begining of <result> and the end of </result> and shows whats in the middle.
report zrich_0001 line-size 500.
data: result_start type i.
data: result_end type i.
data: offset type i.
data: xml_string type string.
xml_string = '<?xml version="1.0" encoding="utf-8"?><result>' &
'<id_5067ea774ce37c4a998c56c296ef383e>' &
'<id_6182ead1dd8fe74abe9feccb316a86d3>' &
'This is my additional info for the customer.' &
'</id_74592f01f5cc2440a87fedda3754db8e> ' &
'</result></survey>'.
search xml_string for '<result>'.
if sy-subrc = 0.
result_start = sy-fdpos.
endif.
search xml_string for '</result>'.
if sy-subrc = 0.
result_end = sy-fdpos.
endif.
* the plus nine accounts for the "</result>"
offset = ( result_end - result_start ) + 9.
write:/ xml_string+result_start(offset).
check sy-subrc = 0.
Regards,
Rich Heilman
‎2006 Jun 07 9:18 PM
I hope I understood you correctly. This program finds the begining of <result> and the end of </result> and shows whats in the middle.
report zrich_0001 line-size 500.
data: result_start type i.
data: result_end type i.
data: offset type i.
data: xml_string type string.
xml_string = '<?xml version="1.0" encoding="utf-8"?><result>' &
'<id_5067ea774ce37c4a998c56c296ef383e>' &
'<id_6182ead1dd8fe74abe9feccb316a86d3>' &
'This is my additional info for the customer.' &
'</id_74592f01f5cc2440a87fedda3754db8e> ' &
'</result></survey>'.
search xml_string for '<result>'.
if sy-subrc = 0.
result_start = sy-fdpos.
endif.
search xml_string for '</result>'.
if sy-subrc = 0.
result_end = sy-fdpos.
endif.
* the plus nine accounts for the "</result>"
offset = ( result_end - result_start ) + 9.
write:/ xml_string+result_start(offset).
check sy-subrc = 0.
Regards,
Rich Heilman
‎2006 Jun 07 9:47 PM
Rich:
Sometimes you just miss the obvious. I was starting down the road you provided when your email came in.
Thanks, it was the ticket. Points awarded.