I have a process with an XML variable, i.e.
var myXML = <package>
<assets>
<foo name="A">....</foo>
<foo name="B">....</foo>
<foo name="C">....</foo>
</assets>
</package>
and I need to add an additional subtree <foo name="D">...</foo> to this variable under /package/assets/.
I am trying to use SetValue but cannot get it to work.
What's the best way to do this?
Views
Replies
Total Likes
Hi,
I did this befor but I do not know if it is th e"best way", what I did is simply cut and paste, substirng and concatenate.
let me show you an example:
in a SetValue use the following variables and their values (expressions)
/process_data/xmlVar1 deserialize('<package> <assets> <foo name="A">....</foo> <foo name="B">....</foo>
<foo name="C">....</foo> </assets> </package>')
/process_data/@strXmlVar serialize(/process_data/xmlVar1, true)
/process_data/@strNewXml '<foo name="D">....</foo>'
/process_data/@strXmlVar concat(substring-before(/process_data/@strXmlVar,
"</assets>"),/process_data/@strNewXml,
"</assets>",substring-after(/process_data/@strXmlVar, "</assets>"))
/process_data/xmlNewVar deserialize(/process_data/@strXmlVar)
Regards
Hussam
Views
Replies
Total Likes