ā2020 Sep 29 6:23 PM
Hello,
I need to upload a XML file and edit the XML to add a new node.
I try to use FUNCTION 'GUI_UPLOAD' and FUNCTION 'SMUM_XML_PARSE' but with this output i can“t add a new node.
Best Regards,
Eduardo Paiva
ā2020 Sep 29 6:30 PM
Hi pedro.guerreiro.gaspar,
Please kindly look into this wiki and advise if this address your topic
https://wiki.scn.sap.com/wiki/display/ABAP/iXML+-+Create+XML+file?original_fqdn=wiki.sdn.sap.com
Cheers,
Luis
ā2020 Sep 30 10:48 AM
Hi LuĆs,
In my search i reach to this link and I have a draft of what I want, code below:
DATA: lo_xml TYPE REF TO cl_xml_document,
lo_root TYPE REF TO if_ixml_node,
lo_xslt TYPE REF TO cl_xslt_processor,
lv_xml TYPE string.
lv_xml = '<NFe><serie>01</serie><nNF>573512</nNF><dEmi>2014-05-06</dEmi><hEmi>16:40</hEmi><item nro="1"><cod>50</cod><desc>Agua</desc></item><item nro="2"><cod>10</cod><desc>Refrigerante</desc></item><totais><valor>R$ 50,00</valor></totais></NFe>'.
CREATE OBJECT lo_xml.
lo_xml->parse_string( stream = lv_xml ).
CREATE OBJECT lo_xslt TYPE cl_xslt_processor.
lo_root = lo_xml->get_first_node( ).
lo_xslt->set_source_node( lo_root ).
lo_node = lo_xml->create_simple_element(
name = 'Company'
* parent = lo_node
VALUE = 'test').
lo_root->append_child( lo_node ).
with this code i can add a node Company with value test, but now i need to upload my XML to put in lv_xml variable.

Best Regards,
Eduardo Paiva
ā2020 Sep 30 6:54 AM
You say "I need to upload a XML", it's not really your question, but it's part of context, please separate the question clearly. SMUM_XML_PARSE is to read "simple XML", it's not to change it.
Please search the Web, there are many questions and answers about "how to edit XML"
Please provide details if you want more relevant answers.
ā2020 Sep 30 2:50 PM
Dear Sandra,
With the code below(draft/example) i can add a node Company with value test, but now i need to upload my XML to put in lv_xml variable.
DATA: lo_xml TYPE REF TO cl_xml_document,
lo_root TYPE REF TO if_ixml_node,
lo_xslt TYPE REF TO cl_xslt_processor,
lv_xml TYPE string.
lv_xml = '<NFe><serie>01</serie><nNF>573512</nNF><dEmi>2014-05-06</dEmi><hEmi>16:40</hEmi><item nro="1"><cod>50</cod><desc>Agua</desc></item><item nro="2"><cod>10</cod><desc>Refrigerante</desc></item><totais><valor>R$ 50,00</valor></totais></NFe>'.
CREATE OBJECT lo_xml.
lo_xml->parse_string( stream = lv_xml ).
CREATE OBJECT lo_xslt TYPE cl_xslt_processor.
lo_root = lo_xml->get_first_node( ).
lo_xslt->set_source_node( lo_root ).
lo_node = lo_xml->create_simple_element(
name = 'Company'
* parent = lo_node
VALUE = 'test').
lo_root->append_child( lo_node ).

Best Regards,
Eduardo Paiva