XML edits. One file, multiple changes, export to multiple

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

Post Reply
Posts: 2
Joined: Fri Aug 20, 2010 4:51 pm

XML edits. One file, multiple changes, export to multiple

Post by shafty » Fri Aug 20, 2010 5:11 pm

Hi guys,

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.

So inside the XML i have this tag:

Code: Select all

I then have a list of ID numbers that need to replace the hashes:

Code: Select all

And then i need to export a seperate XML file for each ID Number:

Code: Select all

If i cant do that, then can i create multiple copies of the XML and name them ID Number.xml, then run a run a find and replace using the list of ID Numbers against the directory of XML files.

My brain hurts!

User avatar
DataMystic Support
Site Admin
Posts: 2211
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia

Re: XML edits. One file, multiple changes, export to multipl

Post by DataMystic Support » Mon Aug 23, 2010 12:10 pm

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.

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

Posts: 2
Joined: Fri Aug 20, 2010 4:51 pm

Re: XML edits. One file, multiple changes, export to multipl

Post by shafty » Mon Aug 23, 2010 3:22 pm

thanks guy, ill give it a try! 8)

Posts: 11
Joined: Sun Oct 09, 2005 8:15 pm

Re: XML edits. One file, multiple changes, export to multipl

Post by Moz » Tue Feb 15, 2011 10:09 pm


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:

Filter options
| [ ] 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.


(917 Bytes) Downloaded 289 times

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests