[HELP] Search Text File and Replace

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi I am complete noob but need some help ASAP (not sure if this is correct forum)
Basically I have an xml file, which I need to edit, see below (the * are just editted data, so work dont complain )
<pre class="prettyprint" style=" <ORDERS>
<ORDER>
<ORDER_ID>**37597****</ORDER_ID>
<ORDER_DATE>2011-10-26</ORDER_DATE>
<ORDER_TYPE>STD</ORDER_TYPE>
<CREDIT_CARD_NUMBER>5006</CREDIT_CARD_NUMBER>
<DESPATCH_NOTE>
<BRAND>GB</BRAND>
</DESPATCH_NOTE>
<RECIPIENT>
<NAME><![CDATA[* *******]]></NAME>
<EMAIL>********</EMAIL>
<ADDRESS>
<ADDRESS_LINE_1><![CDATA[The **** *****]]></ADDRESS_LINE_1>
<ADDRESS_LINE_2><![CDATA[**** Head Yard]]></ADDRESS_LINE_2>
<ADDRESS_LINE_3><![CDATA[]]></ADDRESS_LINE_3>
<TOWN><![CDATA[FURNESS]]></TOWN>
<COUNTY><![CDATA[******]]></COUNTY>
<POSTCODE><![CDATA[**** *HF]]></POSTCODE>
<COUNTRY>GB</COUNTRY>
</ADDRESS>
</RECIPIENT>
<GIFT_MESSAGE>
<GIFT_MESSAGE_LINE_1><![CDATA[5078]]></GIFT_MESSAGE_LINE_1>
<GIFT_MESSAGE_LINE_2><![CDATA[20.00]]></GIFT_MESSAGE_LINE_2>
<GIFT_MESSAGE_LINE_3><![CDATA[40.97]]></GIFT_MESSAGE_LINE_3>
</GIFT_MESSAGE>
<DELIVERY_LINE><ORDER_LINE_ID>1</ORDER_LINE_ID>
<SKU>1365225</SKU>
<QUANTITY>1</QUANTITY>
<UNIT_PRICE CURRENCY="GBP <VALUE>*.**</VALUE>
</UNIT_PRICE>
<DISCOUNT_PRICE CURRENCY="GBP <VALUE>0.00</VALUE>
</DISCOUNT_PRICE></DELIVERY_LINE>
<ORDER_LINE>
<ORDER_LINE_ID>1</ORDER_LINE_ID>
<SKU>2302383</SKU>
<QUANTITY>1</QUANTITY>
<DESCRIPTION><![CDATA[**********]]></DESCRIPTION><UNIT_PRICE CURRENCY="GBP <VALUE>****</VALUE>
</UNIT_PRICE>
<DISCOUNT_PRICE CURRENCY="GBP <VALUE>****</VALUE>
</DISCOUNT_PRICE></ORDER_LINE>[/code]
Ok, so that is the XML file, it will have this reoccuring for all the orders within that file.
Everytime it says
<pre class="prettyprint" style=" <ORDER_LINE_ID>1</ORDER_LINE_ID>
<SKU>2302383</SKU>[/code]
I want to replace the numbers between <SKU></SKU>, with another SKU from a list...
E.G. Find
<pre class="prettyprint" style=" <ORDER_LINE_ID>1</ORDER_LINE_ID>
<SKU>2302383</SKU>[/code]
Replace
<pre class="prettyprint" style=" <ORDER_LINE_ID>1</ORDER_LINE_ID>
<SKU>1234567</SKU>[/code]
The only reason I am struggling is because <SKU></SKU> occurs beneath

<pre class="prettyprint" style=" <DELIVERY_LINE><ORDER_LINE_ID>1</ORDER_LINE_ID>[/code]
I dont want to alter this SKU as it is the DELIVERY SKU, I only wish to adjust the ITEM SKU (SKU above<DESCRIPTION><!)
So find and replace with a RANDOM SKU from a LIST.
E.G. 1234567, 8910111, 1213141, 5161718, 1920212 etc etc

Is this possible? <br/>
And if so would anyone mind showing? :)

THANKS in ADVANCE!


<br/>

View the full article
 
Back
Top