I have to manage an e-catalog and I need to change the price values of it by a percentage of the original values given by my supplier.
the xml file has this kind of structure, but over 1000 items long:
<E_CATALOG>
<item>
<MATERIAL_NUM>000000000000004720</MATERIAL_NUM>
<MATERIAL_DESCR>ΑΝΑΛΩΣ HP INK NO 45 BLACK 42ML</MATERIAL_DESCR>
<EAN_UPC>88698603659</EAN_UPC>
<PART_NUMBER>51645AE</PART_NUMBER>
<SUPPLIER>HP</SUPPLIER>
<CATEGORY>Αναλώσιμα</CATEGORY>
<SUBCATEGORY>Μελάνια</SUBCATEGORY>
<IMAGE_URL>~/getmetafile/483396b2-38ea-4cb1-9856-877dc0b3b066/product-4720-main.aspx</IMAGE_URL>
<PRICE>65.05</PRICE>
<ATP_QUANTITY>0</ATP_QUANTITY>
</item>
<item>
<MATERIAL_NUM>000000000000008879</MATERIAL_NUM>
<MATERIAL_DESCR>ΑΝΑΛΩΣ EPSON A4 PAPER PHOTO MATT 100SH</MATERIAL_DESCR>
<EAN_UPC>10343812017</EAN_UPC>
<PART_NUMBER>C13S041061</PART_NUMBER>
<SUPPLIER>EPSON</SUPPLIER>
<CATEGORY>Είδη γραφείου</CATEGORY>
<SUBCATEGORY>Χαρτικά Αναλώσιμα</SUBCATEGORY>
<IMAGE_URL>~/getmetafile/65f7ee5b-7ad7-43e8-a476-896c72dff8c4/product-8879-main.aspx</IMAGE_URL>
<PRICE>18.10</PRICE>
<ATP_QUANTITY>6</ATP_QUANTITY>
</item>
<item>
<MATERIAL_NUM>000000000000010228</MATERIAL_NUM>
<MATERIAL_DESCR>ΑΝΑΛΩΣ EPSON RIBBON BLACK C13S015022</MATERIAL_DESCR>
<EAN_UPC>10343600447</EAN_UPC>
<PART_NUMBER>C13S015022</PART_NUMBER>
<SUPPLIER>EPSON</SUPPLIER>
<CATEGORY>Αναλώσιμα</CATEGORY>
<SUBCATEGORY>Μελανοταινίες</SUBCATEGORY>
<IMAGE_URL>~/getmetafile/c2c00f78-b088-4690-8143-33f4fb4233f5/product-10228-main.aspx</IMAGE_URL>
<PRICE>9.05</PRICE>
<ATP_QUANTITY>0</ATP_QUANTITY>
</item>
</E_CATALOG>
I tried some suggestions I found online for a different project but somewhat similar aproach. No luck so far. Using Notepad++
He is a powershell script that will work
using assembly System.Xml.Linq
$inputFilename = 'c:\temp\test.xml'
$outputFilename = 'c:\temp\test1.xml'
$doc = [System.Xml.Linq.XDocument]::Load($inputFilename)
$multiplier = [decimal]0.50
$prices = $doc.Descendants('PRICE')
foreach($price in $prices)
{
$price.Value = $multiplier * [decimal]$price.Value
}
$doc.Save($outputFilename)