We have some partners that send their product orders via an XML file. Which they send to our server using FTP. A Windows command line script will take it from the FTP server and send it to our AS400/System I. Where it will be processed into a registered order.
Now are we starting to work with a new partner which sends us XML in the same way as other partners the only problem is that this XML is made of 1 long line of code instead of a pretty print lay out. This is a problem for the AS400 program.
I would like to ad some code in the Windows command line script to get a line break after each end tag.
For example:
Here is a part of the original XML
<?xml version="1.0" encoding="UTF-8"?><czavinh3 xmlns="urn:com.sap.b1i.vplatform:entity"><envelope><sender>Lottum</sender><receiver>8714253093123</receiver></envelope><message><docnum>1122259</docnum><docdtm>2015-09-28</docdtm><txts>test1234</txts>
Here is an example of what the as400 wants
<?xml version="1.0" encoding="UTF-8"?>
<czavinh3 xmlns="urn:com.sap.b1i.vplatform:entity">
<envelope>
<sender>Lottum</sender>
<receiver>8714253093123</receiver>
</envelope>
<message>
<docnum>1122259</docnum>
<docdtm>2015-09-28</docdtm>
<txts>test1234</txts>
I think the fastest way is to search and replace the >< for a >(enter)< this is easily done bye hand but I have no idea how to automate this
Not being a great programmer made my question a bit of a hard problem. Talking with some friends who have some more programming experience told me about FART (Find and Replace Text)
Download here.
This tool is an exe file witch allows you to change the ASCII from files. My problem was that the incoming XML file is made out of 1 string this was a problem for processing it.
With the following statement I changed the XML to a Pretty Print file by entering a break line
fart -c --c-style input.xml "><" ">\r<"
The option -c --c-style allows you to use c-cstyle extended characters like \r (Carriage Return)
Here are the other options u can use
Find And Replace Text v1.99b by Lionello Lunesu
Usage: FART [options] [--] <wildcard>[,...] [find_string] [replace_string]
Options:
-h, --help Show this help message (ignores other options)
-q, --quiet Suppress output to stdio / stderr
-V, --verbose Show more information
-r, --recursive Process sub-folders recursively
-c, --count Only show filenames, match counts and totals
-i, --ignore-case Case insensitive text comparison
-v, --invert Print lines NOT containing the find string
-n, --line-number Print line number before each line (1-based)
-w, --word Match whole word (uses C syntax, like grep)
-f, --filename Find (and replace) filename instead of contents
-B, --binary Also search (and replace) in binary files (CAUTION)
-C, --c-style Allow C-style extended characters (\xFF\0\t\n\r\\ etc.)
--cvs Skip cvs dirs; execute "cvs edit" before changing files
--svn Skip svn dirs
--remove Remove all occurences of the find_string
-a, --adapt Adapt the case of replace_string to found string
-b, --backup Make a backup of each changed file
-p, --preview Do not change the files but print the changes