Tuesday, January 24, 2006

TraverToy4: Extracting Source Code from XML

TraverToy4 is very similar to TraverToy1. The difference is that TraverToy1 removes blank lines from source code, while TraverToy4 extracts the source code from the XML file and allows you to save it as a text file. (Important: No indenting is done. I hope to return to that topic sometime in the future.)

XML is similar to HTML. In fact, an XHTML file is an XML file. The most important thing to realize is that important pieces of data are surrounded, left and right, by angle brackets discribing the data.

For example, take this line of XHTML:

C.S. Lewis's <b>most</b> popular children's book is <i>The Lion, the Witch, and the Wardroble</i>.

The <b> and </b> "bookends" indicate that the word "most" is to be put in bold type. The <i> and </i> "bookends" indicate that "The Lion, the Witch, and the Wardrobe" is to be put in italic print. (Note, by the way, that the right closing tag has a right slash ("/") immediately after the first angle bracket.)

Similarly, in REALbasic's XML format, <SourceLine> and </SourceLine> are the "bookends" used to enclose REALbasic source. Extract from the file what you've got between those two tags, and you have all the source code. It's as simple as that.

To use TraverToy4, Open an XML file, Process the file, and save the result as a TXT file. If you want to take a look at how indenting can be done, you can download RB CodeHelper Lite (RBCHL), but hold off on doing that until tomorrow (Wednesday, January 25, 2006),by which time I hope to have available an improved version, with some features added and some bugs removed.

TraverToy4 should work equally well on a Mac as in Windows, but I don't have a Mac myself (yet), so I can't guarantee that it will work properly "as is" on the Mac. If you as a Mac user have to make any minor modifications, I hope you'll let me know, so that I can pass the information for the benefit of other Mac users of REALbasic. (For example, I'm not quite sure how the Mac handles FileTypes, but I know it works a bit differently from the way it works in Windows.)

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home