‎2012 Nov 08 11:31 PM
I have to convert a xml file in to internal table , my xml file is very well formed,
but this function module says the xml file has syntax error.
please let me kn ow where i am making mistake
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = g_xmldata
TABLES
xml_table = g_t_xml_info
return = g_t_return
EXCEPTIONS
OTHERS = 0.
‎2012 Nov 09 8:12 AM
Hi,
Did you convert the XML String to XSTRING?
If so, did you respect the XML encoding when you did the conversion ?
-
Andrei
‎2012 Nov 09 9:23 AM
Yes I converted to XML string into X string,
and how can I take care about encoding ? what I need to perform for encoding ?
‎2012 Nov 09 9:36 AM
Hi,
Check FM SCMS_STRING_TO_XSTRING. You can either input the encoding (the sap encoding code) or the mime-type.
But, can you give us the exact error you get and the xml string ?
-
Andrei
‎2012 Nov 09 10:23 AM
mycode is as follows
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
DATA: l_xml_table TYPE TABLE OF t_xml_line,
DATA: g_t_xml_info TYPE TABLE OF smum_xmltb INITIAL SIZE 0.
DATA: g_t_return TYPE STANDARD TABLE OF bapiret2.
DATA: g_xmldata TYPE xstring.
START-OF-SELECTION.
* Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
* Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
INPUT_LENGTH = 2000
FIRST_LINE = 1
LAST_LINE = 1
IMPORTING
BUFFER = g_xmldata
TABLES
BINARY_TAB = l_xml_table
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = g_xmldata
TABLES
xml_table = g_t_xml_info
return = g_t_return
EXCEPTIONS
OTHERS = 0.
the XML string :
3C3F786D6C2076657273696F6E3D22312E30223F3E3C44617461656C656D656E7473
3E3C4669656C64733E3C5355424F424A454354205355424F424A4543543D2244445445585
4202020203030303031222F3E3C4C414E4755414745206C616E67756167653D224445222F3E3C4C
454E475448204C656E6774683D22363020222F3E3C5445585420546578743D2245696E7A656C6E6573205
3415020446F6B756D656E74222F3E3C2F4669656C64733E3C4669656C64733E3C5355424F424A45435420535
5424F424A4543543D22444454455854202020203030303032222F3E3C4C414E4755414745206C616E67756167653D224445222F3E3C4C454E4754
‎2012 Nov 10 11:40 PM
Kiran marina, it seems that the function module works perfectly, but the XML data that you want to be parsed is no XML. It contains many question marks (hex 3F) which spoil the XML syntax.
When I decode the hex data that you posted in your note from Nov 9, 2012 11:23 AM (in response to Andrei Sosea), they look like this:
<?xml version="1.0"?><Dataelements?><Fields>
<SUBOBJECT SUBOBJECT="DDTEX?? 00001"/>
<LANGUAGE language="DE"/><L?ENGTH Length="60 "/><TEXT Text="Einzelnes ??AP Dokument"/></Fields><Fields><SUBOBJECT S??BOBJECT="DDTEXT 00002"/><LANGUAGE language="DE"/><LENGT...
Even very well-meaning XML parsers would complain about these data.
Regards,
Rüdiger
‎2012 Nov 11 12:46 AM
hi rüdiger,
is there a method or function module so that I can check my XML file before extracting it.
actually i need to download data from abap internal table to XML , then this XML is opened in Excel file
and the excel file is modified ,then all the changes will be recorded in XML file , I need to extract this modified XML file again in to internal table.
this is the whole proces, can u suggest me how can I make my XML file syntax error free so that I can easily download in to Internal table and then i can process the data.
‎2012 Nov 11 5:59 AM
Kiran, if you are downloading to Excel consider using CSV or Tab delimited formats.
From your code I assume this is the code to upload the XML back to your program.
To upload from Excel to Internal table, you can use ALSM_EXCEL_TO_INTERNAL_TABLE if the file is in .XLS format.
For upload/download with XML, consider using XML Transformation if appropriate.
You can get more information here:
http://wiki.sdn.sap.com/wiki/display/Snippets/XML+XLS+transformation
http://help.sap.com/saphelp_nw04/helpdata/en/86/8280d212d511d5991b00508b6b8b11/content.htm
Hope this helps.
Thanks,
Vimal