Friday, January 15, 2010

XML

I have been doing some web work for a friend of mine. While I am not a hot shot web designer by any means, I am familiar with most of the technologies involved and have put together a few websites. Though I am not nearly artistic enough to 'design' a site nor crafty enough to put together all those fancy clever scripts and such that coders use to coerce the DOM into doing what it should in the first place.
This website was interesting to me as it is based on Flash. Flash is used in those annoying animated ads you see on your webmail page, as well as in those design-ey websites. It is also how more than a little 2D animation gets done these days. South Park being a well known example of Flash being used for broadcast production. I am under the impression that much of what is done over at Williams Street is based in Flash as well.
At first I thought I had an onerous Flash website task in front of me, so I downloaded the whole site to my drive and dug around looking for some FLA files.
Nothing! If you are going to design a site for someone it is only common courtesy to give them the source code of any live deliverables in case future updates need to be made. Sure they could come back to you for future jobs but guess what, you may be dead, had your laptop stolen or switched careers by then.
After further tinkering with the local copy of the site I deduced that even though it is based in Flash, the content is configured in a few XML files. This is fairly clever as editing Flash requires a copy of Flash CS4 be installed on your computer, while editing XML can in theory be done with the simplest text editor you can imagine, like Notepad or Simpletext.

I mapped out the directories and dug around in the HTML to figure out which directories were live. This was not easy. Some images appeared in multiple directories. The HTML basically only shows that a Javascript is pushing out the Flash content.

I ended up viewing "page info" in firefox to ascertain which flash files were active in which HTML pages.
I changed the name of the image directories until a name change broke the code and made the Flash literally draw a blank.

Then I was looking at the XML directory's files thinking that it might belong to the webhost's site control panel. Maybe it will give me a site map? I already unsuccessfully tried mapping the site manually into an Excel table. What can I say I like organizing things in Excel. All that did was waste a day and point out that a previous webmaster had been backdooring the site to host their (or a friends) resume!
Turns out the XML files pointed to the directories I had already sussed as likely the correct picture repositories.
So then I do the responsible thing and make a safe copy of the XML files. Then I start monkeying with them. Looks like I am on to something! I change the name in the XML. The name changes in the Flash! Well it works for the text. For images I have to clear my browser cache and restart the browser before I see changes.

Well I got all the pretty pictures up, but the text, which I thought was the easy part, is not cooperating. It shows up properly in the right place and time. However for some reason when I duplicate the syntax as it appears in the old version I get double spaced line breaks. The original is somehow able to get single spaced line breaks without resorting to any XML properties that I can see. Okay, well maybe the problem is that I am not seeing all of the XML attributes properly when I open it in Notepad. I think I need to try an XML editor? So I make the big mistake of downloading and installing Microsoft's XML Notepad 2007. Not a good idea. Completely hosed all the XML that I had already edited! Do not download XML Notepad 2007. Do not install it. Do not open work that you only have one copy of and edit it!
The edited work has a bunch of escape characters everyplace I inserted whitespace or tabbed things into place. This has the effect of breaking the XML and causing the Flash viewer to parse it as garbage.
So do I go back to my saved version and edit out the garbage or re-do it?
I am a lazy man so this is quite a conundrum.
I drink more coffee and do it all over again.
As of this writing I havent solved the double line space problem. It looks alright, but not as tight. I think I may need to edit it on a mac?

1 comment:

  1. As a follow up I stumbled upon the excellent notepad++. This is what XML notepad 2007 should be. It can parse XML, HTML and CSS and even has a handy dandy autocomplete function. I love text editors with autocopmlete. IT helps to keep you in correct syntax when you aren't sure about the available properties for a particular attribute.
    I also ended up getting around the hidden line break dilemma by simply cutting and pasting the old code and inserting the new stuff on top of it.
    Wish I had found Notepad++ earlier it would have made this task much simpler!

    ReplyDelete