CreateCommonXML is done..

By some miracle, in all this utter madness :’-( I managed to debug one small program that I also wrote today. All the program does is build a kind of common XML, that is, one element with all the subelements it finds, and for each element, its attributes.

On simple 2 XML files it works well, for example from:

XML
<shop>
    <sale>
        <item1 id="23">
            <name>Some stuff</name>
            <price>23.42</price>
        </item1>
        <item1 id2="42" id="32">
            <name>Some other stuff</name>
            <price currency="EUR">42.23</price>
        </item1>
    </sale>
</shop>

and from:

XML
<shop>
    <stock>
        <item2>
            <amount>456</amount>
        </item2>
        <item4 id="42">
            <amount>123</amount>
        </item4>
    </stock>
</shop>

You get this:

XML
<shop>
    <sale>
        <item1 id="23" id2="42">
            <name>Some stuff</name>
            <price currency="EUR">23.42</price>
        </item1>
    </sale>
    <stock>
        <item2>
            <amount>456</amount>
        </item2>
        <item4 id="42">
            <amount>123</amount>
        </item4>
    </stock>
</shop>

As you can see, the second XML is exactly the same (it was only there so I could check whether the program can merge files), but in the first one changes were made – all the tags and attributes were merged into a single element item1. However, on more complex XML, such as a partial dump of my FB wall, which has 79556 lines in the original, it cut it down to just 44908. The culprit, as far as I can tell, is mainly the fact that <table class="walllink"> contains all sorts of HTML..

I already tried to skip it, but I don’t really understand my own code, because I didn’t get where I wanted. Okay, I’m giving up on it for now, someday I’ll finish it so that it can handle anything, and hopefully I’ll learn that when something is HTML, it’s not wise to parse it as XML! 🙂 I’m still thinking about what to do with the code, someone might find it useful, but I think I won’t publish it anywhere and will wait until I find time to polish it to the point where it can hopefully handle everything.

Categories

Leave a Reply