mIRC Homepage
Posted By: cyberock XML Support - 12/12/02 09:07 PM
I was thinking about this and see no reason for this not to be possible, why not embed some sort of XML parser, i know there is already ini config files support which could be used to store info but an XML parser would be much better. let me know what you think grin

thanks
-rock
Posted By: codemastr Re: XML Support - 12/12/02 11:21 PM
I'm one of those people who hates XML even though I know it is gonna be used more and more so I don't like the idea personally. But as I said XML is being used more and more, so I guess it is a good idea. If Khaled doesn't wanna add it I'm sure it would be relatively easy to do with a dll.
Posted By: starbucks_mafia Re: XML Support - 12/12/02 11:37 PM
How would it work though? I would imagine the code to access a subnode several levels deep would look horrible in any format based on mIRC's scripting syntax. In my opinion XML is something which requires more advanced programming concepts than mIRC scripting can provide to make comprehensive support. And with that in mind it would be pointless to make those additions simply for XML.

If you can think of a syntax which would work then by all means correct me, but as it is I can't see any implementation that wouldn't look pretty damn awful - then again, I don't have much of an imagination.
Posted By: codemastr Re: XML Support - 13/12/02 12:30 AM
I'm not too familiar with XML but a simple 'slash syntax' for parent-child relations could work...

node/subnode/subsubnode/subsubsubnode

But like I say, not too familiar with XML so I could be totally wrong.
Posted By: GrimZ Re: XML Support - 13/12/02 05:28 AM
Probably the majority of people who would want XML in mIRC don't see much multi-level nodes.

Most commonly XML (that people see) is single level based (I did say commonly) and that wouldn't be hard to make a parser with a simple loop an regex/gettok.

But for finite level nodes you'd just need to do some recursion and regex/gettok (I'd use regex) but with recursion (I know it's not *technically* possible without timers/dummy aliases calls) you could probably easily figure out how to make the hierarchy.

I don't personally think it would be very hard just take some logic and planning. But of course it wouldn't be as efficent as one in C/C++ like Khaled could provide ... but then again, there's no fun in that =P
Posted By: starbucks_mafia Re: XML Support - 13/12/02 02:27 PM
The problem with that being that the subnodes wouldn't necessarily be distuinguishable using text to identify them.
For example here's a simple XML file:

Code:
<library>
  <book>
    <title>The Big Book of mIRC</title>
    <author>K. Mardam-Bey</author>
    <review>
      <source>NY Times</source>
      <content>Wow, what a great book</content>
    </review>
    <review>
      <source>Arnie</source>
      <content>Moo!</content>
    </review>
  </book>
  <book>
    <title>Monopolising The Marketplace</title>
    <author>B. H. Gates</author>
    <review>
      <source>PC Buyer</source>
      <content>Blah blah blah...</content>
    </review>
  </book>
  <book>
    <title>XML For Dummies</title>
    <author>W. W. Web</author>
  </book>
</library>


Now, say you wanted to get Arnie's review of 'The Big Book of mIRC'.
Immediately you've got a problem in that all the children of 'library' are called 'book' - no simple text identifier available. With a language that had arrays etc. that wouldn't be a problem, it would simply be a case of referring to it as library/book[0] (assuming a 0-based array). With mIRC there's no such luck, using traditional mIRC syntax the way to identify that would be something like $xmlsub(library,book,1) - which doesn't look too bad.
So then we move on to getting the correct 'review' subnode, again there's more than one node of the same type, with the array-enabled language it's just a matter of library/book[0]/review[1], but what would that look like for mIRC? The previous $xmlsub usage is useless since it wouldn't return an object, just $true. How would be refer to it? I suppose it could simply use some syntax which resembled the array style, but then it wouldn't follow traditional mIRC syntaxing and could be misleading to a newcomer who might think he was dealing with actual arrays.

I'm not trying to put down the idea of XML functionality in mIRC, I use XML myself a fair bit in webdev, it just seems a bit of a stretch at the moment.
Posted By: GrimZ Re: XML Support - 13/12/02 05:27 PM
You do have a good point... arrays would be so much easier to use as a method of storing things and mIRC don't provide them.

Posted By: vcv Re: XML Support - 14/12/02 03:11 AM
Khaled is welcome to use the XML engine I am writing in C++ to offer support via scripting.

codemastr made a good sueggestion about using a path-style syntax to access the data.. which is exactly what my engine is going to use.

For example, let's take the xml data s_m posted.. to access <source>PC Buyer</source>, you would pass /library/book[1]/review/source to a function called..say... $getxmldata.

Or..in this casem, there is an undefined number of books in the library..so an iterator could be offered that could work similar to tokens..

Code:
var %child_count = $xml_child_count(/library)
var %i = 1
while (%i &lt;= %child_count) {
   echo -a $xml_get_data(/library/book[ $+ %i $+ ]/review/source)
}


or something along the lines. the details are a bit sketchy.. but i think its a nice idea.
Posted By: Necroman Re: XML Support - 14/12/02 07:13 AM
I guess you use the XML parser by Microsoft?
Posted By: FunChatter Re: XML Support - 14/12/02 01:22 PM
Just by curiosity XML stands for?
Posted By: Merlin Re: XML Support - 14/12/02 01:26 PM
Extensible Markup Language (XML) - read about it http://www.w3.org/XML/
Posted By: vcv Re: XML Support - 15/12/02 01:55 AM
No, Necroman. It is/will be written from scratch, as is most of my stuff.
Posted By: codemastr Re: XML Support - 16/12/02 08:28 PM
Reinventing the wheel isn't always a good thing...
Posted By: vcv Re: XML Support - 16/12/02 11:26 PM
Of course not.. but I'd rather have my XML parser be stand-alone and not depend on MS's xml thing.

Take my xmenu dll for example.. I didn't need to do it..there is alternatives...menus already exist... but well, my menus are faster than the office xp/vs.net menus and look/behave the same.
Posted By: tom420 Re: XML Support - 19/12/02 04:04 AM
E-mail me your XML library, or a link to a website about it smile
(unless it commercial/proprietary, of couse)
© mIRC Discussion Forums