xml reformat

General discussions about Advanced Find and Replace
Post Reply
wlukasik
Posts: 10
Joined: Mon Aug 13, 2007 3:36 pm

xml reformat

Post by wlukasik » Mon Aug 13, 2007 3:58 pm

Roman,

I need to take this xml format:

<Document>
<Attr name="CurrentDocumentInStream" value="1" />
<Attr name="CurrentDocumentInPartition" value="1" />
<Attr name="CurrentDocumentInPackage" value="1" />
<Attr name="IsLastDocumentOfPackage" value="true" />
<Attr name="TotalPagesInDocument" value="3" />
<Attr name="TotalRectoPagesInDocument" value="3" />
<Attr name="TotalVersoPagesInDocument" value="0" />
<Attr name="TotalBlankPagesInsertedInDocument" value="0" />
<Attr name="TotalSheetsInDocument" value="3" />
<Attr name="ASSSIGNED_TO" value="000PL3021" />
<Attr name="AUTH_UID" value="" />
<Attr name="AUTHOR_NAME" value="Scott Gunn" />
<Attr name="Category" value="GC_PROPERTY_DAMAGE" />
<Attr name="GC_AUTHOR" value="Scott Gunn" />
<Attr name="GC_CLAIM_NO" value="2007-080009" />
<Attr name="InBound_Doc_Type" value="001221" />
<Attr name="Letter" value="GC_DRIVERS_STATEMENT_LTR" />
<Attr name="NJM_Random_GUID" value="D1C79B05418D7D705C68B3601BD3E640" />
<Attr name="OutBound_Doc_Type" value="OUTBND_DOCTYP" />
</Document>


And change it to this:

<Document>
<CurrentDocumentInStream>1</CurrentDocumentInStream>
<CurrentDocumentInPartition>1</CurrentDocumentInPartition>
<CurrentDocumentInPackage>1</CurrentDocumentInPackage>
<TotalPagesInDocument>3</TotalPagesInDocument>
<TotalRectoPagesInDocument>3</TotalRectoPagesInDocument>
<TotalVersoPagesInDocument>0</TotalVersoPagesInDocument>
<TotalBlankPagesInsertedInDocument>0</TotalBlankPagesInsertedInDocument>
<TotalSheetsInDocument>3</TotalSheetsInDocument>
<ASSSIGNED_TO>000PL3021</ASSSIGNED_TO>
<AUTH_UID>7876</AUTH_UID>
<AUTHOR_NAME>Scott Gunn</AUTHOR_NAME>
<Category>GC_PROPERTY_DAMAGE</Category>
<GC_AUTHOR>Scott Gunn</GC_AUTHOR>
<GC_CLAIM_NO>2007-08000</GC_CLAIM_NO>
<InBound_Doc_Type>001221</InBound_Doc_Type>
<Letter>GC_DRIVERS_STATEMENT_LTR</Letter>
<NJM_Random_GUID>D1C79B05418D7D705C68B3601BD3E640</NJM_Random_GUID>
<OutBound_Doc_Type>OUTBND_DOCTYP</OutBound_Doc_Type>
</Document>

How can I do that?

Thanks much,

Walt

Abacre
Site Admin
Posts: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Re: xml reformat

Post by Abacre » Mon Aug 13, 2007 4:12 pm

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
<Attr name="(.*)" value="(.*)" />

Replace with:
<$1>$2</$1>

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

wlukasik
Posts: 10
Joined: Mon Aug 13, 2007 3:36 pm

Re: xml reformat

Post by wlukasik » Mon Aug 13, 2007 4:20 pm

Roman, you are the man! What a great tool. You need to charge more!

Thanks for the help.

Walt

wlukasik
Posts: 10
Joined: Mon Aug 13, 2007 3:36 pm

Re: xml reformat

Post by wlukasik » Mon Aug 13, 2007 6:29 pm

Roman, one more thing. What is the syntax for command line processing this file?

Walt

Abacre
Site Admin
Posts: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Re: xml reformat

Post by Abacre » Mon Aug 13, 2007 9:22 pm

It depends on what do you want to do.
The list of command line parameters is defined here:
http://www.abacre.com/afr/manual/commandline.htm

For example, you may save configuration file as c:\afr\test.cfg. Then you may use the following:
afr -execute:batch -config c:\afr\test.cfg -min -exit
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

wlukasik
Posts: 10
Joined: Mon Aug 13, 2007 3:36 pm

Re: xml reformat

Post by wlukasik » Tue Aug 14, 2007 12:06 pm

Roman, this format worked fine (afr -execute:batch -config c:\afr\test.cfg -min -exit). I was trying to run it off a network drive but for some reason, it didn't work. Thanks again.

Walt

:D :D

wlukasik
Posts: 10
Joined: Mon Aug 13, 2007 3:36 pm

Re: xml reformat

Post by wlukasik » Wed Aug 15, 2007 12:29 pm

Roman, still another last question. In the file:

<!--wl-->
<Package>
<Document>
<CurrentDocumentInStream>1</CurrentDocumentInStream>
<CurrentDocumentInPartition>1</CurrentDocumentInPartition>
<CurrentDocumentInPackage>1</CurrentDocumentInPackage>
<IsLastDocumentOfPackage>true</IsLastDocumentOfPackage>
<TotalPagesInDocument>5</TotalPagesInDocument>
<TotalRectoPagesInDocument>5</TotalRectoPagesInDocument>
<TotalVersoPagesInDocument>0</TotalVersoPagesInDocument>
<TotalBlankPagesInsertedInDocument>0</TotalBlankPagesInsertedInDocument>
<TotalSheetsInDocument>5</TotalSheetsInDocument>
<ASSSIGNED_TO>000BM5045</ASSSIGNED_TO>
<AUTH_UID></AUTH_UID>
<AUTHOR_NAME>Beth Mandel</AUTHOR_NAME>
<Category>GC_PROPERTY_DAMAGE</Category>
<GC_AUTHOR>Beth Mandel</GC_AUTHOR>
<GC_CLAIM_NO>2007-080013</GC_CLAIM_NO>
<InBound_Doc_Type>001217</InBound_Doc_Type>
<Letter>GC_DELETE_COVERAGE_LTR</Letter>
<NJM_Random_GUID>065FB77D498AD638215200CDF8D1AA7F</NJM_Random_GUID>
<OutBound_Doc_Type>OUTBND_DOCTYP</OutBound_Doc_Type>
</Document>
<!-- Package Level Attributes -->
<CurrentPackageInStream>1</CurrentPackageInStream>
<CurrentPackageInPartition>1</CurrentPackageInPartition>
<TotalSheetsInPackage>5</TotalSheetsInPackage>
<TotalPackageWeight>0.0</TotalPackageWeight>
<TotalPackageThickness>0.0</TotalPackageThickness>
<TotalPagesInPackage>5</TotalPagesInPackage>
<TotalRectoPagesInPackage>5</TotalRectoPagesInPackage>
<TotalVersoPagesInPackage>0</TotalVersoPagesInPackage>
<TotalBlankPagesInsertedInPackage>0</TotalBlankPagesInsertedInPackage>
</Package>
<!-- Partition Level Attributes -->
<PartitionNO>1</PartitionNO>
<TotalPagesInPartition>5</TotalPagesInPartition>
<TotalRectoPagesInPartition>5</TotalRectoPagesInPartition>
<TotalVersoPagesInPartition>0</TotalVersoPagesInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<TotalSheetsInPartition>5</TotalSheetsInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<!--wl-->
<!--wl-->
<Package>
<Document>
<CurrentDocumentInStream>1</CurrentDocumentInStream>
<CurrentDocumentInPartition>1</CurrentDocumentInPartition>
<CurrentDocumentInPackage>1</CurrentDocumentInPackage>
<IsLastDocumentOfPackage>true</IsLastDocumentOfPackage>
<TotalPagesInDocument>8</TotalPagesInDocument>
<TotalRectoPagesInDocument>8</TotalRectoPagesInDocument>
<TotalVersoPagesInDocument>0</TotalVersoPagesInDocument>
<TotalBlankPagesInsertedInDocument>0</TotalBlankPagesInsertedInDocument>
<TotalSheetsInDocument>8</TotalSheetsInDocument>
<ASSSIGNED_TO>000BM5045</ASSSIGNED_TO>
<AUTH_UID></AUTH_UID>
<AUTHOR_NAME>MaryAnn O&apos;hara</AUTHOR_NAME>
<Category>GC_HOMEOWNERS</Category>
<GC_AUTHOR>MaryAnn O&apos;hara</GC_AUTHOR>
<GC_CLAIM_NO>2007-080013</GC_CLAIM_NO>
<InBound_Doc_Type>001218</InBound_Doc_Type>
<Letter>GC_CONDITIONS_AND_DUTIES_LTR</Letter>
<NJM_Random_GUID>B5F8276517064D7958A8A9DBFA491B39</NJM_Random_GUID>
<OutBound_Doc_Type>OUTBND_DOCTYP</OutBound_Doc_Type>
</Document>
<!-- Package Level Attributes -->
<CurrentPackageInStream>1</CurrentPackageInStream>
<CurrentPackageInPartition>1</CurrentPackageInPartition>
<TotalSheetsInPackage>8</TotalSheetsInPackage>
<TotalPackageWeight>0.0</TotalPackageWeight>
<TotalPackageThickness>0.0</TotalPackageThickness>
<TotalPagesInPackage>8</TotalPagesInPackage>
<TotalRectoPagesInPackage>8</TotalRectoPagesInPackage>
<TotalVersoPagesInPackage>0</TotalVersoPagesInPackage>
<TotalBlankPagesInsertedInPackage>0</TotalBlankPagesInsertedInPackage>
</Package>
<!-- Partition Level Attributes -->
<PartitionNO>1</PartitionNO>
<TotalPagesInPartition>8</TotalPagesInPartition>
<TotalRectoPagesInPartition>8</TotalRectoPagesInPartition>
<TotalVersoPagesInPartition>0</TotalVersoPagesInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<TotalSheetsInPartition>8</TotalSheetsInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<!--wl-->
<!--wl-->
<Package>
<Document>
<CurrentDocumentInStream>1</CurrentDocumentInStream>
<CurrentDocumentInPartition>1</CurrentDocumentInPartition>
<CurrentDocumentInPackage>1</CurrentDocumentInPackage>
<IsLastDocumentOfPackage>true</IsLastDocumentOfPackage>
<TotalPagesInDocument>1</TotalPagesInDocument>
<TotalRectoPagesInDocument>1</TotalRectoPagesInDocument>
<TotalVersoPagesInDocument>0</TotalVersoPagesInDocument>
<TotalBlankPagesInsertedInDocument>0</TotalBlankPagesInsertedInDocument>
<TotalSheetsInDocument>1</TotalSheetsInDocument>
<ASSSIGNED_TO>000JM4615</ASSSIGNED_TO>
<AUTH_UID></AUTH_UID>
<AUTHOR_NAME>Scott Gunn</AUTHOR_NAME>
<Category>GC_PROPERTY_DAMAGE</Category>
<GC_AUTHOR>Scott Gunn</GC_AUTHOR>
<GC_CLAIM_NO>2007-080008</GC_CLAIM_NO>
<InBound_Doc_Type>001221</InBound_Doc_Type>
<Letter>GC_DRIVERS_STATEMENT_LTR</Letter>
<NJM_Random_GUID>0EBEF8A3585FA1BC44534E05A43023D3</NJM_Random_GUID>
<OutBound_Doc_Type>OUTBND_DOCTYP</OutBound_Doc_Type>
</Document>
<!-- Package Level Attributes -->
<CurrentPackageInStream>1</CurrentPackageInStream>
<CurrentPackageInPartition>1</CurrentPackageInPartition>
<TotalSheetsInPackage>1</TotalSheetsInPackage>
<TotalPackageWeight>0.0</TotalPackageWeight>
<TotalPackageThickness>0.0</TotalPackageThickness>
<TotalPagesInPackage>1</TotalPagesInPackage>
<TotalRectoPagesInPackage>1</TotalRectoPagesInPackage>
<TotalVersoPagesInPackage>0</TotalVersoPagesInPackage>
<TotalBlankPagesInsertedInPackage>0</TotalBlankPagesInsertedInPackage>
</Package>
<!-- Partition Level Attributes -->
<PartitionNO>1</PartitionNO>
<TotalPagesInPartition>1</TotalPagesInPartition>
<TotalRectoPagesInPartition>1</TotalRectoPagesInPartition>
<TotalVersoPagesInPartition>0</TotalVersoPagesInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<TotalSheetsInPartition>1</TotalSheetsInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<!--wl-->
<!--wl-->
<Package>
<Document>
<CurrentDocumentInStream>1</CurrentDocumentInStream>
<CurrentDocumentInPartition>1</CurrentDocumentInPartition>
<CurrentDocumentInPackage>1</CurrentDocumentInPackage>
<IsLastDocumentOfPackage>true</IsLastDocumentOfPackage>
<TotalPagesInDocument>3</TotalPagesInDocument>
<TotalRectoPagesInDocument>3</TotalRectoPagesInDocument>
<TotalVersoPagesInDocument>0</TotalVersoPagesInDocument>
<TotalBlankPagesInsertedInDocument>0</TotalBlankPagesInsertedInDocument>
<TotalSheetsInDocument>3</TotalSheetsInDocument>
<ASSSIGNED_TO>000PL3021</ASSSIGNED_TO>
<AUTH_UID></AUTH_UID>
<AUTHOR_NAME>Scott Gunn</AUTHOR_NAME>
<Category>GC_PROPERTY_DAMAGE</Category>
<GC_AUTHOR>Scott Gunn</GC_AUTHOR>
<GC_CLAIM_NO>2007-080009</GC_CLAIM_NO>
<InBound_Doc_Type>001221</InBound_Doc_Type>
<Letter>GC_DRIVERS_STATEMENT_LTR</Letter>
<NJM_Random_GUID>D1C79B05418D7D705C68B3601BD3E640</NJM_Random_GUID>
<OutBound_Doc_Type>OUTBND_DOCTYP</OutBound_Doc_Type>
</Document>
<!-- Package Level Attributes -->
<CurrentPackageInStream>1</CurrentPackageInStream>
<CurrentPackageInPartition>1</CurrentPackageInPartition>
<TotalSheetsInPackage>3</TotalSheetsInPackage>
<TotalPackageWeight>0.0</TotalPackageWeight>
<TotalPackageThickness>0.0</TotalPackageThickness>
<TotalPagesInPackage>3</TotalPagesInPackage>
<TotalRectoPagesInPackage>3</TotalRectoPagesInPackage>
<TotalVersoPagesInPackage>0</TotalVersoPagesInPackage>
<TotalBlankPagesInsertedInPackage>0</TotalBlankPagesInsertedInPackage>
</Package>
<!-- Partition Level Attributes -->
<PartitionNO>1</PartitionNO>
<TotalPagesInPartition>3</TotalPagesInPartition>
<TotalRectoPagesInPartition>3</TotalRectoPagesInPartition>
<TotalVersoPagesInPartition>0</TotalVersoPagesInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<TotalSheetsInPartition>3</TotalSheetsInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<!--wl-->
<!--wl-->
<Package>
<Document>
<CurrentDocumentInStream>1</CurrentDocumentInStream>
<CurrentDocumentInPartition>1</CurrentDocumentInPartition>
<CurrentDocumentInPackage>1</CurrentDocumentInPackage>
<IsLastDocumentOfPackage>true</IsLastDocumentOfPackage>
<TotalPagesInDocument>3</TotalPagesInDocument>
<TotalRectoPagesInDocument>3</TotalRectoPagesInDocument>
<TotalVersoPagesInDocument>0</TotalVersoPagesInDocument>
<TotalBlankPagesInsertedInDocument>0</TotalBlankPagesInsertedInDocument>
<TotalSheetsInDocument>3</TotalSheetsInDocument>
<ASSSIGNED_TO>000DC5353</ASSSIGNED_TO>
<AUTH_UID></AUTH_UID>
<AUTHOR_NAME>Beth Mandel</AUTHOR_NAME>
<Category>GC_PROPERTY_DAMAGE</Category>
<GC_AUTHOR>Beth Mandel</GC_AUTHOR>
<GC_CLAIM_NO>2007-080002</GC_CLAIM_NO>
<InBound_Doc_Type>001217</InBound_Doc_Type>
<Letter>GC_DELETE_COVERAGE_LTR</Letter>
<NJM_Random_GUID>59C79BBD539C06EEE581F301586A877C</NJM_Random_GUID>
<OutBound_Doc_Type>OUTBND_DOCTYP</OutBound_Doc_Type>
</Document>
<!-- Package Level Attributes -->
<CurrentPackageInStream>1</CurrentPackageInStream>
<CurrentPackageInPartition>1</CurrentPackageInPartition>
<TotalSheetsInPackage>3</TotalSheetsInPackage>
<TotalPackageWeight>0.0</TotalPackageWeight>
<TotalPackageThickness>0.0</TotalPackageThickness>
<TotalPagesInPackage>3</TotalPagesInPackage>
<TotalRectoPagesInPackage>3</TotalRectoPagesInPackage>
<TotalVersoPagesInPackage>0</TotalVersoPagesInPackage>
<TotalBlankPagesInsertedInPackage>0</TotalBlankPagesInsertedInPackage>
</Package>
<!-- Partition Level Attributes -->
<PartitionNO>1</PartitionNO>
<TotalPagesInPartition>3</TotalPagesInPartition>
<TotalRectoPagesInPartition>3</TotalRectoPagesInPartition>
<TotalVersoPagesInPartition>0</TotalVersoPagesInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<TotalSheetsInPartition>3</TotalSheetsInPartition>
<TotalBlankPagesInsertedInPartition>0</TotalBlankPagesInsertedInPartition>
<!--wl-->

How do I change only the first and last occurance of <!--wl--> to <Partition> and </Partition> respectively. Again, thanks for the help.

Walt

Abacre
Site Admin
Posts: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Re: xml reformat

Post by Abacre » Wed Aug 15, 2007 1:11 pm

Go to main menu - Action - Options - Batch Replace
check "Modifier S"
check "Modifier G"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
<!--wl-->(.*)<!--wl-->

Replace with:
<Partition>$1</Partition>

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

wlukasik
Posts: 10
Joined: Mon Aug 13, 2007 3:36 pm

Re: xml reformat

Post by wlukasik » Wed Aug 15, 2007 1:47 pm

Thanks again!

Walt

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests