Not sure if you can help me or not, but here's what I'm trying to do.
I have one XML file that i need to turn into many XML files, replacing one dummy bit of code with an ID number from a list. That then needs to export the file as a new XML file with a filename of the ID number being imported in.
Hmm. You could use a scripting filter as a subfilter of the search/replace, so that it replaces with a new string each time.
You might be better off using File Menu\Export to VBScript, to generate a script that you can apply again and again to the one original file, and generate a new output file each time using your search/replace list as the input.
Not sure if you managed to work this out or not, but I do a similar thing with Textpipe.
Is your finished XML file always the same except for the UserID? If so then you can start with the following filters and change to match your XML file structure.
There are a couple of problems which I've listed at the end, but maybe Simon can suggest how to fix these?
1. Make a text file containing all your UserIDs, one on each line.
2. Make a note of how many lines your finished XML will have.
3. Add these filters:
| [ ] Log to file
| [X] Append to logfile
| Log filename: textpipe.log
| Threshold 500
|--Input from file(s)
| [ ] Confirm before processing each file
| [ ] Confirm before processing read/only files
| [ ] Delete input files after processing
| Process binary files
|--Restrict to each line in turn
| |--Capture to variable @XMLID
| | Reset: 1
| +--Perl pattern [([^\r\n])*?] with [<BeginningOfXMLUpToTheIDNumber>\r\n<userRefId>$0</userRefID>\r\n<EndOfXMLAfterTheIDNumber>]
| [ ] Match case
| [ ] Whole words only
| [ ] Case sensitive replace
| [ ] Prompt on replace
| [ ] Skip prompt if identical
| [ ] First only
| [ ] Extract matches
| Maximum text buffer size 4096
| [ ] Maximum match (greedy)
| [ ] Allow comments
| [X] '.' matches newline
| [ ] UTF-8 Support
|--Split after 3 lines, filename @XMLID, number 0
+--Output to file(s)
[ ] Only update date on changed files
[ ] Append mode
[X] Change extension to: .xml
[ ] Open output file
Output folder: C:\Users\Admin\Desktop\test
[ ] Maintain folder structure
[X] Remove empty output files
(note that the Capture Variable and PErl replacement filters are both subfilters of "Restrict to each line in turn".)
4. Change filter number 5 (Split after xx lines) to tell it how many lines your finished XML file will have.
5. Run this against your XMLID.txt file.
I've attached a zip file with my example filter and a test ID file.
- When I run on my machine the @XMLID variable starts as a blank variable and the first file that is output is ".xml". Not sure how to fix this?
- When I run on my machine I get an error when it renames the TMP files to the @XMLID.xml name. The error is like "Couldn't move file [C:\Users\Admin\Desktop\temp\TXP8D4.tmp] to [C:\Users\Admin\Desktop\temp\m1m41.xml] The filename, directory name, or volume label syntax is incorrect.