Page 1 of 1

Edit and XML Tag

Posted: Thu Jun 05, 2014 3:52 pm
by John.Dean
I am trying to edit a tag in an XML file. The value for an XML tag related to quantity needs to be changed to 110% of that value. Obviously, you cannot perform math functions in metadata path. Also, there are instances where that value is, "N/A" and not an integer.



What is the simplest way to make this edit? I'm assuming scripting is the answer.

Edit and XML Tag

Posted: Thu Jun 05, 2014 5:47 pm
by dkelly
You can use XSLT (Freddy would say)



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:template match="order">

<xsl:value-of select="quantity*1.1"/>

</xsl:template>

</xsl:stylesheet>





or you could write a simple script to open, modify and write the XML file or dataset



Edit and XML Tag

Posted: Thu Jun 05, 2014 6:02 pm
by freddyp
"Well, it depends on how the value is used" Freddy would say :)



When you need the 110% value in the XML then what Dwight says is of course correct.



However, when you only need the 110% value inside Switch you can actually perform the calculation in Switch without any XSL or scripting. In the variables pane you go to Switch - Calculation first and you open an Expression. This opens another instance of the variables pane and there you browse to the metadata value that you need and you insert the variable. Now you add the calculation you want to perform on this variable, so you add *1.1 after it. You now have an expression that will be calculated by Switch. Not in this pane yet; there you only see the formula, but when you click OK to return to the previous pane you will see the calculated result.

Edit and XML Tag

Posted: Fri Jun 06, 2014 8:47 pm
by John.Dean
Great. Thanks, guys. I'll let you know how it goes.