‎2011 Sep 10 6:19 PM
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
‎2011 Sep 10 6:56 PM
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
‎2011 Sep 10 6:56 PM
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
‎2011 Sep 10 7:23 PM
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.
‎2011 Sep 10 8:04 PM
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
‎2016 Mar 08 1:46 PM
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
‎2016 Mar 08 3:29 PM
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.