May 25, 2013 Re: Best XML Library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Idan Arye | > I suggest you check the XMLP library by Michael Rynn. I tried XML processing with D, so I don't know how good the different libraries are, but XMLP is on the review queue, which means it's highly possible it will become Phobos' standard XML library, and when that happens you will have an easy migration.
That is a good point. I suppose I'll take a look at that and
Tango's XML package.
|
May 28, 2013 Re: Best XML Library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Fri, 24 May 2013 10:18:37 -0400, Adam D. Ruppe <destructionator@gmail.com> wrote:
> On Friday, 24 May 2013 at 12:56:54 UTC, Andrea Fontana wrote:
>> On Thursday, 23 May 2013 at 22:22:26 UTC, Meta wrote:
>>> I'm thinking of starting on a small XMPP-based messaging
>
>>
>> You should give a try to dom.d by adam ruppe:
>
>
> I don't think it would work best for xmpp though because dom.d needs the entire file before it can parse, and xmpp is a stream of data.
AFAIK, Tango's xml is the same.
-Steve
|
May 28, 2013 Re: Best XML Library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Friday, 24 May 2013 at 14:18:38 UTC, Adam D. Ruppe wrote: > I don't think it would work best for xmpp though because dom.d needs the entire file before it can parse, and xmpp is a stream of data. I just decided to write a quick stream like thing, to see if I can, and it actually kinda works. My dom.d is still NOT an ideal choice for xmpp, I was just wondering if I could do this easily and figured I'd share the results. dom.d https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d also needs characterencodings.d from that same github. === import arsd.dom; import std.stdio; void main() { auto document = new Document(); document.eventObservers ~= delegate(DomMutationEvent event) { if(event.operation == DomMutationOperations.appendChild) { auto element = event.related; if(element.tagName == "cool") writeln("GOT: " ~ element.toString()); } }; document.parseStream(new Utf8Stream(delegate string() { return readln(); }, delegate bool() { return stdin.isOpen; }), true, true); } === $ dmd streamtest.d dom.d characterencodings.d $ ./streamtest # I type the tags there into the console <test> <cool>sweet</cool> GOT: <cool>sweet</cool> # note how this showed up instantly </test> The parse function expected a complete string, and I didn't signficantly modify it. Instead I created a class Utf8Stream that overloads enough operators that it can pretend to be a string, but one that can fetch more data when its length is checked and it is close to the last index fetched (the parse function checks data.length often to avoid going out of bounds, and it fetches chars by opIndex one at a time, so it works here, but wouldn't likely work elsewhere. Heck it might even break with non-ascii input, I haven't tried that yet) So yeah pretty hacky, but since it internally builds the tree and fires off these mutation event things, you can hook into that and react as it is built, accomplishing the task at hand, more or less. But since it is still building a big old dom and appending strings internally, it will be a bit of a memory hog as time goes on, and performance may not be great. It also works better in strict mode (The true, true on the parse function argument list does this) than garbage mode when streaming. Like I said, dom.d still isn't my first choice for xmpp or any other enormous xml parsing task, but hey it kinda works and is fairly convenient so if this looks useful to you, have fun! |
June 13, 2013 Re: Best XML Library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Thursday, 23 May 2013 at 22:22:26 UTC, Meta wrote: > I'm thinking of starting on a small XMPP-based messaging client and server, which would necessitate quite an extensive use of XML. Since Tango is no longer being maintained, and Vibe.d doesn't support XML (as far as I know), what would be the best option for XML capabilities? Some time ago, I contacted the xmlp developers about this type of parsing. They made some changes and shared these links with me. http://bazaar.launchpad.net/~michael-rynn-500/d2-xml/d2-xml-dev/view/head:/alt/jabber.d http://bazaar.launchpad.net/~michael-rynn-500/d2-xml/d2-xml-dev/view/head:/test/jclient.d http://bazaar.launchpad.net/~michael-rynn-500/d2-xml/d2-xml-dev/view/head:/test/jserver.d |
June 14, 2013 Re: Best XML Library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Thursday, 23 May 2013 at 22:22:26 UTC, Meta wrote:
> I'm thinking of starting on a small XMPP-based messaging client and server, which would necessitate quite an extensive use of XML. Since Tango is no longer being maintained, and Vibe.d doesn't support XML (as far as I know), what would be the best option for XML capabilities?
Additional requirement: You need a streaming XML parser (aka event-based or SAX).
Is it Open Source? I was thinking about doing something similar.
|
June 14, 2013 Re: Best XML Library | ||||
---|---|---|---|---|
| ||||
Posted in reply to qznc | On 2013-06-14 10:49, qznc wrote: > Additional requirement: You need a streaming XML parser (aka event-based > or SAX). Tango has a SAX parser. > Is it Open Source? I was thinking about doing something similar. -- /Jacob Carlborg |
Copyright © 1999-2021 by the D Language Foundation