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

save xstring as XML file

Former Member
0 Likes
4,378

Hey guys,

is there a way to save a xstring as XML file? There ist a function modul which i can use to convert it to a table SMUM_XML_PARSE. But i want to save it directly without converting it to a table an then create a xml and save.

thx,

Ming

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
2,274

Hi Wei Ming,

an xstring may contain any non-character data.

XML

Valid characters

Main article: Valid characters in XML

Unicode code points in the following ranges are valid in XML 1.0 documents:[9]

U0009, U000A, U000D: these are the only C0 controls accepted in XML 1.0;+

U0020u2013UD7FF, UE000u2013UFFFD: this excludes some (not all) non-characters in the BMP (all surrogates, UFFFE and UFFFF are forbidden);

U10000u2013U10FFFF: this includes all code points in supplementary planes, including non-characters.

XML 1.1[10] extends the set of allowed characters to include all the above, plus the remaining characters in the range U0001u2013U001F. At the same time, however, it restricts the use of C0 and C1 control characters other than U0009, U000A, U000D, and U0085 by requiring them to be written in escaped form (for example U0001 must be written as  or its equivalent). In the case of C1 characters, this restriction is a backwards incompatibility; it was introduced to allow common encoding errors to be detected.+

The code point U+0000 is the only character that is not permitted in any XML 1.0 or 1.1 document.

Could you give an example of hexa xstring content and expected XML result?

Regards

Clemens

5 REPLIES 5
Read only

Clemenss
Active Contributor
0 Likes
2,275

Hi Wei Ming,

an xstring may contain any non-character data.

XML

Valid characters

Main article: Valid characters in XML

Unicode code points in the following ranges are valid in XML 1.0 documents:[9]

U0009, U000A, U000D: these are the only C0 controls accepted in XML 1.0;+

U0020u2013UD7FF, UE000u2013UFFFD: this excludes some (not all) non-characters in the BMP (all surrogates, UFFFE and UFFFF are forbidden);

U10000u2013U10FFFF: this includes all code points in supplementary planes, including non-characters.

XML 1.1[10] extends the set of allowed characters to include all the above, plus the remaining characters in the range U0001u2013U001F. At the same time, however, it restricts the use of C0 and C1 control characters other than U0009, U000A, U000D, and U0085 by requiring them to be written in escaped form (for example U0001 must be written as  or its equivalent). In the case of C1 characters, this restriction is a backwards incompatibility; it was introduced to allow common encoding errors to be detected.+

The code point U+0000 is the only character that is not permitted in any XML 1.0 or 1.1 document.

Could you give an example of hexa xstring content and expected XML result?

Regards

Clemens

Read only

Former Member
0 Likes
2,274

Hi,

the xstring was build by one of my routine. I created a XML via the SAP XML library (iXML) and converted it to a xstring. Now i want to convert the xtsring back into the XML. How can i do this? Sure i could create a XML table with the DOM object, but now i want to convert it back from the xstring. Is there a way to use the iXML library?

thx,

Ming.

Read only

0 Likes
2,274

Hi,

you use the iXML stream factory to create the input stream from the xstring, and then you parse it into the iXML document.


DATA lo_ixml TYPE REF TO if_ixml.
DATA lo_streamfactory TYPE REF TO if_ixml_stream_factory.
lo_ixml = cl_ixml=>create( ).
lo_streamfactory = lo_ixml->create_stream_factory( ).
DATA lo_istream TYPE REF TO if_ixml_istream.
lo_istream = lo_streamfactory->create_istream_xstring( string = your_xstring ).
DATA lo_document TYPE REF TO if_ixml_document.
lo_document = lo_ixml->create_document( ).
DATA lo_parser TYPE REF TO if_ixml_parser.
lo_parser = lo_ixml->create_parser( stream_factory = lo_streamfactory
                                      istream        = lo_istream
                                      document       = lo_document ).
lo_parser->parse( ). "<=== fill lo_document from your_xstring

Then you can play with lo_document

sandra

Read only

Former Member
0 Likes
2,274

Hi Sandra Rossi

Can you tell me in which variable we get the XML value.

DATA lo_ixml TYPE REF TO if_ixml.

DATA lo_streamfactory TYPE REF TO if_ixml_stream_factory.

DATA lo_istream TYPE REF TO if_ixml_istream.

DATA lo_document TYPE REF TO if_ixml_document.

DATA lo_parser TYPE REF TO if_ixml_parser.

lo_ixml = cl_ixml=>create( ).

lo_streamfactory = lo_ixml->create_stream_factory( ).

lo_istream = lo_streamfactory->create_istream_xstring( string = your_xstring ).

lo_document = lo_ixml->create_document( ).

lo_parser = lo_ixml->create_parser( stream_factory = lo_streamfactory

                                      istream        = lo_istream

                                      document       = lo_document ).

lo_parser->parse( ). "<=== fill lo_document from your_xstring

https://scn.sap.com/thread/3874784

Thanks,

Madhu M V

Read only

0 Likes
2,274

Madhu, the XML goes to the variable "your_xstring"

edit: sorry, it's a code to load "your_xstring" variable into an iXML instance, that you may query using the iXML methods.