Notepad++ and xml - replacing

خرید بک لینک

I have an XML file (1000s of records, simplified here), structure (e.g. say):

<LIST>
<ITEM_0>
<NAME>Item Name</NAME>
</ITEM_0>
...
<ITEM_9999>
<NAME>Item Name</NAME>
</ITEM_9999>
</LIST>

I need result:

<LIST>
<ITEM>
<ID>0</ID>
<NAME>Item Name</NAME>
</ITEM>
...
<ITEM>
<ID>9999</ID>
<NAME>Item Name</NAME>
</ITEM>
</LIST>

Using Regex:

Find: <ITEM_(.*)(>)
Replace: ITEM>n<ID>1</ID>

I get:

<LIST>
<ITEM>
<ID>0</ID>
<NAME>Item Name</NAME>
</ITEM>
<ID>0</ID> <-- This line not wanted
...
<ITEM>
<ID>9999</ID>
<NAME>Item Name</NAME>
</ITEM>
<ID>9999</ID> <-- This line not wanted
</LIST>

It's replacing </ITEM> AS WELL even though (I think) I'm asking it to only replace <ITEM>- what am I doing wrong/how to fix? I may be missing something regarding grouping (or 'greedy'?) but not sure what and have looked all over for similar. There's a million ways to cut and dice it with something else, but it just bugs me getting so close but not there with NPP.

Help appreciated- thanks.

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 301 تاريخ: يکشنبه 10 مرداد 1395 ساعت: 18:55

صفحه بندی