How to adjust text in a xml file
Q: How can I setup a watch folder for any xml files come in and search for specific wording and change it to another word and move it out to an output directory.
For the attach example:
- If you see the word “ <Main>1</Main>” then change to <Main>Good</Main>
- If you see other word beside “1” then chang to <Main>NoGood</Main>
Example content:
<?xml version=”1.0″?>
<Header>
<Main>1</Main>
<name>Geen</name>
<Date>221023</Date>
</Plan>
A: Yes this is possible using ‘Pascal Script’ as Destination.
Source is a Windows folder:
We adjusted the ‘Include Filename Filter’ to *.xml because we only want to handle xml files here.
We added our ‘Pascal Script’ option as Destination:
We added the following script. Please do not forget to adjust the ctOutputPath const which must end with a \
You can download the script: here
RunTime Log result:
Content of the 3 source test files we used:
1. TEST.Good.xml
<?xml version=”1.0″?>
<Header>
<Main>1</Main>
<name>Geen</name>
<Date>221023</Date>
</Plan>
2. TEST.NoGood.xml
<?xml version=”1.0″?>
<Header>
<Main>0</Main>
<name>Geen</name>
<Date>221023</Date>
</Plan>
3. TEST.NoGood.blanc.xml
<?xml version=”1.0″?>
<Header>
<Main></Main>
<name>Geen</name>
<Date>221023</Date>
</Plan>
Content of the 3 resulting Destination files:
1. TEST.Good.xml
<?xml version=”1.0″?>
<Header>
<Main>Good</Main>
<name>Geen</name>
<Date>221023</Date>
</Plan>
2. TEST.NoGood.xml
<?xml version=”1.0″?>
<Header>
<Main>NoGood</Main>
<name>Geen</name>
<Date>221023</Date>
</Plan>
3. TEST.NoGood.blanc.xml
<?xml version=”1.0″?>
<Header>
<Main>NoGood</Main>
<name>Geen</name>
<Date>221023</Date>
</Plan>
#xml #filetransfer #filemanagement
If you need any help with this ‘adjust text in a xml file’ request, please let us know.
Best Regards,
Limagito Team