Batch editing XML file

Hi,

Not sure this is in the right category but I’m guessing my problem might need to use PHP queries to work. But I may be wrong!..

I have an XML file with around 40,000 of these type of entry:

<IndexItemAdd> <ItemID> <SupplierPartID>DSY526526</SupplierPartID> </ItemID> <ItemDetail> <UnitPrice> <Money currency="GBP">3.98</Money> </UnitPrice> <Description xml:lang="en">500g</Description> <UnitOfMeasure>1</UnitOfMeasure> <Classification domain="943"></Classification> <ManufacturerPartID>5YS225</ManufacturerPartID> <ManufacturerName>The Brand</ManufacturerName> <Extrinsic name="ProductBarCode">546728549162354</Extrinsic> <Extrinsic name="ProductBarCodeList">502121252154122</Extrinsic> <Extrinsic name="PartName">Product Name Here</Extrinsic> <Extrinsic name="SubCategoryName">Chemicals</Extrinsic> <Extrinsic name="VATPercentage">20.0</Extrinsic> <Extrinsic name="PartSpecification">EProduct description goes here</Extrinsic> <Extrinsic name="ImageFile">http://www.website.com/uploads/image.jpg</Extrinsic> <Extrinsic name="ImageWidth">250</Extrinsic> <Extrinsic name="ImageHeight">250</Extrinsic> </ItemDetail> <IndexItemDetail> <LeadTime></LeadTime> </IndexItemDetail> <SupplierList> <Supplier> <Name xml:lang="en">The Supplier</Name> <SupplierID domain="ATRCompanyID">AC57586572</SupplierID> <UnitPrice> <Money currency="GBP">1.86</Money> </UnitPrice> <Extrinsic name="WholesalerUnitOfMeasure">1</Extrinsic> <Extrinsic name="WholesalerPartID">542653</Extrinsic> <Extrinsic name="WholesalerListPrice">2.32</Extrinsic> <Extrinsic name="WholesalerPrice">2.32</Extrinsic> <Extrinsic name="WholesalerRRP">3.98</Extrinsic> <Extrinsic name="WholesalerEndOfLine">No</Extrinsic> <Extrinsic name="WholesalerPromotion" ends=""></Extrinsic> <Extrinsic name="WholesalerExcludeDiscounts">No</Extrinsic> <Extrinsic name="WholesalerPackPrice" pack="12">26.45</Extrinsic> <Extrinsic name="WholesalerPackDiscountPrice" pack="12">21.16</Extrinsic> </Supplier> </SupplierList> </IndexItemAdd>

The problem is I need to change the “WholesalerPrice” extrinsic to 0.75 times the value in the file. For all 40,000 items. Any ideas?!

Thanks in advance!

since it’s nicely formatted, preg_replace_callback() with file() (or similar). if you have sufficient memory for DOMDocument, that would be a possibility as well.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.