Edit and XML Tag

Post Reply
John.Dean
Newbie
Posts: 8
Joined: Thu May 23, 2013 3:00 pm

Edit and XML Tag

Post 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.
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Edit and XML Tag

Post 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


freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Edit and XML Tag

Post 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.
John.Dean
Newbie
Posts: 8
Joined: Thu May 23, 2013 3:00 pm

Edit and XML Tag

Post by John.Dean »

Great. Thanks, guys. I'll let you know how it goes.
Post Reply