Hi all
I've been playing around with the XML_* functions and the XML VARA. GET_VAR (+ PREP_PROCESS_VAR_XML) has been brought to the new level by supporting XPath / XQuery toaccess/read elements.
Now obviously if I read from data from a source I can modify (VARA XML), I would also like to change it. Now for me it seems that the common XML_* functions seem not to support XPath :-(.
Also I used EXPORT / IMPORT and wanted to modify the export XML using AE script functions. This is unnecessarily complex without the XPath support for the XML_SELECT_NODE. I also realized, that XML_PRINTINTOFILE does create files that do not start with a <?xml...> encoding information - which prevents to IMPORT the file.
i.E. the below code would - in theory - change the title of the current object:
:SET &AESERVER# = 'AESERVER.INTRA.CH'
:SET &EXPORTFILE# = '/tmp/data.xml'
:SET &OBJECTNAME# = &$NAME#
:SET &XML_RET# = EXPORT(&OBJECTNAME#, &EXPORTFILE#)
:SET &HND# = PREP_PROCESS_FILE(&AESERVER#, &EXPORTFILE#)
:SET &XML_PROCESS# = XML_PROCESS_TO_DOM(&HND#)
! For simple, one-object-per-file changes possible, but not powerful without XPath.
:SET &XML_NODE# = XML_SELECT_NODE(&XML_PROCESS#, '/uc-export/SCRI/XHEADER/Title')
:SET &XML_RC# = XML_SET_NODE_TEXT(&XML_NODE#, 'This is my new title.')
:SET &XML_RET# = XML_PRINTINTOFILE('&EXPORTFILE#', &XML_PROCESS#)
:XML_CLOSE
! This won't work because of missing <?xml.. encoding information
:SET &XML_RET# = IMPORT(&EXPORTFILE#)
Is anyone at all using the XML_* functions to mutate export-XMLs or XML VARAs? With all the JSON hype going on I wonder whether XML will survive at all.
Regards
Joel