AddNewLineToEntryNodes: VBA code to add newline characters at start of entry nodes in Blogger XML Backup/Export file to enable easier viewing and editing in Notepad++

Last updated on 9 Sep. 2023 

9 Sep. 2023 Update: I rarely use the software covered in this post now. To see the current software for creating Blogger blogbooks that I use, please visit: Short User Guide to creating Blogger Blogbooks from Backup/Export File using ExportFileFilterAndGenBook and another VBA projects' macros/code (free and open source), https://ravisiyermisc.blogspot.com/2023/09/short-user-guide-to-creating-blogger.html .

end-Update 9 Sep. 2023

Quick Info
End Quick Info

Microsoft Visual Basic for Applications (VBA) Sub./macro AddNewLineToEntryNodes adds newline characters at the beginning of all entry nodes in input Blogger blog backup/export XML file as well as few other nodes, producing an output XML file with these newline characters. This can be done by search & replace manually using Notepad++ too which procedure is described in an info. file whose link is provided later on in this post.

These newline characters result in Notepad++ being able to view each entry node as one or more lines (more lines if the entry itself has newline characters within it). That makes it easier to view and understand the Blogger blog XML export file and also manipulate it manually, for example by removing some entries.

Links of some screenshots (from above folder share) which illustrate the difference are given below:
The above two links are to pics of original Blogger XML Backup/Export file (named 20230801-tns-blog.xml).
The above three links are to pics of output file (named 20230801-tns-blogmod.xml) of AddNewLineToEntryNodes to which the abovementioned Blogger XML Backup/Export file (named 20230801-tns-blog.xml) was provided as input.

The above modified XML export file 20230801-tns-blogmod.xml was provided as input to VBA program/macro BlogExportFileSearchToBook and it produced expected blogbook output file which matched blogbook created using original XML export file - 20230801-tns-blog.xml - except for initial header text having differences in filename and run timestamp. [Ref: BlogExportFileSearchToBook: VBA code to produce HTML blog book from Blogger blog backup/export XML file optionally limited to content matching search string,  https://ravisiyermisc.blogspot.com/2023/08/blogexportfilesearchtobook-vba-code-to.html .]

While I have not tested manual deletion of particular entries and providing that modified XML file to BlogExportFileSearchToBook to produce blogbook that does not have the deleted entries, I am quite sure that it will work based on some additional test programming work I did. This test programming added code to AddNewLineToEntryNodes to only output page and post entries published in 2022, along with all other category (not page or post) entries. The output file of this program was then provided as input to BlogExportFileSearchToBook which produced the expected blogbook having only pages & posts that were published in 2022, along with comment(s) associated with them.

For more about this test programming work, please visit links below:
===========================

An alternate program to AddNewLineToEntryNodes is AddNewLineToEntryNodesSS which takes a different approach by reading entire file contents into a string and then using String Split VBA function to create an array of substrings which are separated by <entry> tag/delimiter and then writes these substrings with newlines separating these substring entries into an output XML export file. The SS suffix to macro name as well as folder name is to indicate version using String Split function.

One significant advantage of this AddNewLineXMLExportFileSS program is that addition of xmlns attribute that happens with AddNewLineXMLExportFile is avoided, and hard-coded entries for initial xml tags and end feed tags are not required.

One possible limitation of this AddNewLineXMLExportFileSS program is that as it reads the whole input file into memory at one go, it will not work for very large XML Backup/export files. However, I have tested it with 20230801-ravisiyermisc-blog-utf16.xml of size 26 MB having UTF-16 character encoding for which it seems to work

This program needs UTF-16 input file. It trips up on UTF-8 input file without giving any indication of it having tripped up.



Run information file which also describes how to use search and replace in Notepad++ to do this task of insertion of newlines manually: RunInfo.txt, https://drive.google.com/file/d/1h7Omf-UQVqHG2WbzEli1FSyYufjTP1Eu/view?usp=drive_link

Comments

Archive

Show more