in reply to the axml parser v3.4

Why do you keep escaping and unescaping the []()?+? And why do you try to parse the XML yourself instead of using a parser? The code would be much much simpler and safer if you did that ... parsing XML with regexps is generally a bad idea. Also I find your s@...@...@ and m@...@ hard to read. If you do not want to use slashes (as they are present in the end tags) use s{...}{} and m{...}. I do think that's much more readable.

Replies are listed 'Best First'.
Re^2: the axml parser v3.4
by simonodell1 (Novice) on Apr 12, 2007 at 11:44 UTC

    Re : Grandfather; thanks I will look into those suggestions in my next verion!

    Re : glory hack; thanks for the constructive part of the critiscm, however imho posting ameture code makes a person look like they are willing to learn something new, saying someone looks a like a dork for being a begginer makes a person look like a snob... whilst I'm sure your perl coding could make mark j dominus look like a noob, manners are universal Sir.

    Re : Jenda, i found that using the ( ) and other such chars caused my regex's to fail, and after many frustrating hours trying to figure out why that is, i decided on the solution you see here.

    I wasn't intending this post to be some sort of statement of programming prowess, I needed some info on capturing data from a given url and the resulting conversation on the chatter box prompted me to share this code. I'm fully aware its both ameture and in need of a lot of work, and thanks to some of the more mature responses here I have some directions in which to take it.

    The code aside, I still think the aim of aXML is valid and worthy of being understood. The ability to nest xml tags which correspond to plugins gives a freedom of expression which makes my development work so much easier.

    Many thanks.

      I strongly recommend that you separate out the parser into its own, reusable module, if you expect other people to pick it up. The fact that it's entwined monolithically with other junk (like a hand-rolled CGI handler) is going to be a major stumbling block for many people who might otherwise be interested in it.

      If you need help modularizing your code, there's some tutorials on the topic here at PerlMonks; and of course you can always ask in the CB or post a SOPW.

      A word spoken in Mind will reach its own level, in the objective world, by its own weight

      If you allow the later example then it's no longer XML. Therefore there is no need for this to look like XML. Especially since it's supposed to be used within HTML. You'd rather use some other syntax ... something that stands out more and that doesn't get confused with the HTML. Or use one of the many existing templating modules.

      Of course if you looked at them and none of them fits your needs, go ahead and build your own. It seems to me like it will be a good learning experience, but nothing more.

      Regarding the () and friends ... you have to escape those in regexps as they have a special meaning. You'd better try to fix the problems with the regexps than to try to circumvent them like this. Post an example of text you are trying to match and fail and the regexp and maybe we can help.

      I like to use # in place of /..... it doesn't look too bad, and works just fine. m# # or s# # # macdaddy.