Replace word found in xml file with new

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Replace word found in xml file with new

08 Dec 2017, 07:58

Code: Select all

Gui, Add, Edit, x22 y30 w130 h30 , APPLE
Gui, Add, Edit, x162 y30 w120 h30 , PEAR
Gui, Add, Button, x312 y30 w100 h30 , Button
Gui, Show, w439 h294, Untitled GUI
return

GuiClose:
ExitApp

return
There is an xml file under the directory c: \ directory.

I want to do;

When we click on the button,

In the first paragraph, you will find the words "Apple" in the XML file "Apple"
I will replace it with the word "Pear" in the 2nd paragraph.

and I want you to give a warning with a message.
2 pieces of "apple" WRITTEN AND CHANGED "
I want you to give your warning.

Can it be provided with code? Thank you.

xml content

Code: Select all

<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="http://www.tnb.org.tr/XSL/ReportBelgeIkiliTasarim.xsl"?>
<ArrayOfBelgeOnay>
  <BelgeOnay>
    <Species >APPLE</Species>
    <Sherry >A</Sherry>
    <Quantity >50</Quantity>
    <Unvan>RAMAZAN TAHMAZ  </Unvan>
    <Name>APPLE</Name>
      
  </BelgeOnay>
</ArrayOfBelgeOnay>
Attachments
aaa.xml
(363 Bytes) Downloaded 20 times
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Replace word found in xml file with new

08 Dec 2017, 13:24

Code: Select all

Gui, Add, Edit, x22 y30 w130 h30 vE1, APPLE
Gui, Add, Edit, x162 y30 w120 h30 vE2, PEAR
Gui, Add, Button, x312 y30 w100 h30 gButton , Run..
Gui, Show, w439 h294, `t
Return

GuiClose:
ExitApp

Button:
   Gui, Submit, NoHide
   FileRead, XMLContent, aaa.xml
   NewXMLContent := StrReplace(XMLContent, E1, E2, Occ)
   FileAppend, % NewXMLContent "`n", new_aaa.xml
   MsgBox % "You've replaced " . E1 . " with " . E2 . " " Occ . " times!"
   Run, notepad new_aaa.xml
   Return
Not tested.
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Replace word found in xml file with new

11 Dec 2017, 04:29

Dear bobo.
Thank you for your help.
But there will be another responsibility.

In the rar file I added in the attachment, there is 1 folder.
This folder contains files with xml extension.
There's an "Ahk" file that you've coded.
I want to

1- It is to find "http://www.abc.com.tr" addresses in the files with all xml extensions in the folder and replace them with "http://www.123abc.com.tr" address.

2-We can also do this with a single "bat" extension file.

Thank you in advance for your help.
Attachments
xml.rar
(1.72 KiB) Downloaded 15 times
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Replace word found in xml file with new

12 Dec 2017, 04:17

please help me for one last step.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, gabelynn1, Spawnova and 170 guests