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

String to XML

Former Member
0 Likes
2,834

Hi Guys,

I have implemented a WS that recieves an XML serialized as a string.

Once i get this string i want to convert it to XML format.

Any idea?

Thanks

11 REPLIES 11
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,139

You have to parse the string into XML. Check the instance method PARSE_STRING of class CL_XML_DOCUMENT.

Check my reply in this thread:

Edited by: Suhas Saha on Jun 11, 2010 3:59 PM

Read only

Former Member
0 Likes
2,139

Right thanks, but where i can see the xml that was created?

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,139

When you parse the string the attribute M_DOCUMENT gets updated.

>

> Where i can see the xml that was created?

What do you mean by this ?

Read only

Former Member
0 Likes
2,139
DATA: lv TYPE sysubrc.
*type-pools: ixml.
class CL_XML_DOCUMENT definition load.
DATA: OBJ type REF TO cl_xml_document.
CREATE OBJECT OBJ.


  CALL METHOD OBJ->PARSE_STRING
    EXPORTING
       STREAM  = '<?xml version="1.0" encoding="iso-8859-1" ?><ARTICULOS><ARTICULO><ACCION>D</ACCION></ARTICULO></ARTICULOS>'
    RECEIVING
      RETCODE = lv.

this is my code, my string has XNL tabs and i want to know where is it parsed.

i want to know where is the xml generated

Edited by: Jon Azkorra Olano on Jun 11, 2010 1:10 PM

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,139

XML is not physically generated. In layman's language the XML is saved as the attribute M_DOCUMENT.

Just add the line obj->display( ) at the end of your code, you can see the XML document generated from the string

BR,

Suhas

Read only

Former Member
0 Likes
2,139

Thanks and is any way to pass the generated xml to an internal table?

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,139

>

> Thanks and is any way to pass the generated xml to an internal table?

You want to convert the XML to internal table ? Check this wiki : [http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table]

Read only

Former Member
0 Likes
2,139

thanks again but i need to pass to the internal table the XML ( i see in obj->display()

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,139

What should be your internal table structure ?

Read only

Former Member
0 Likes
2,139

on my own

Read only

Former Member
0 Likes
2,139

on my own