## D - Which XML parser?

Which D XML parser are you using?

we have an expat port available and should
be better.
Couldn't find it.

Thanks
Ant

Oct 06 2003
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Ant wrote:
Which D XML parser are you using?

we have an expat port available and should
be better.
Couldn't find it.

Thanks
Ant

Ant,

I have attempted to wrap 1.95.3 of the expat parser, with very little luck.
I'm
afraid I'm only a beginner C programmer, and don't totally understand how a lot
of things work, especially with callback functions and function pointers, etc.
I've attached my expat.d wrapper module, so maybe you can take a look and see
what I'm doing wrong.  Also, I had to run implib on the precompiled dll's that
came with the Win version of expat-1.95.3.

I think I might be pretty close.  You may want to try extern(Windows) instead
of
extern(C) in the beginning of expat.d, although I'm not sure of the difference
and Walter or the docs had said at one time to use extern (C) on the whole
wrapper module.  With extern (Windows), it compiles, but then can't find the
dll.

I'll attach my whole project for you.   Unzip by using path/folder info.  The
\ref directory has the originals.

Let me know how you do, and if you succeed, what you did.

Hope this helps...

Oct 08 2003
In article <bm21ua$ng0$1 digitaldaemon.com>, Brad Anderson says...
This is a multi-part message in MIME format.
--------------040803070706080207070403
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Ant wrote:
Which D XML parser are you using?

we have an expat port available and should
be better.

I have attempted to wrap 1.95.3 of the expat parser, with very little luck.
I'm
afraid I'm only a beginner C programmer, and don't totally understand how a lot
of things work, especially with callback functions and function pointers, etc.
I've attached my expat.d wrapper module, so maybe you can take a look

I'm bookmarking this.
If nobody else does I might take a look in a couple of days.
(the best I can do is to give you back a linux version)
Keep us informed if you have any progress.

Thanks

Ant

Oct 08 2003
 I'm bookmarking this.
If nobody else does I might take a look in a couple of days.
(the best I can do is to give you back a linux version)
Keep us informed if you have any progress.

Linux version is fine.  Also, if we make progress, I'll wrap 1.95.6, the latest
release, January 2003, and attempt it for Win32 as well.

I've also been looking at the Java version of Xerces, which has a SAX and a DOM
parser as well as XML 1.1 support.  I'd be much better at converting Java to D,
and I may toy with that in the future.


Oct 09 2003
Mike Hearn <mike theoretic.com> writes:
I did an experimental wrapping of the libxml2 XmlReader API one night, to
get a feel for how hard it would be:

/* -*- mode: c++-mode; c-basic-offset: 4 -*-
*
* Example of using the libxml2 xmlReader API from D
* (c) 2003 Mike Hearn <mike theoretic.com>
*/

import string;

Element = 1,
Attribute =	2,
Text = 3,
CDATA = 4,
EntityRef =	5,
Entity =		6,
ProcessingInstruction = 7,
Comment = 8,
Document = 9,
DocumentType = 10,
DocumentFrag = 11,
Notation = 12,
ElementEnd = 15
}

extern (C) {

/* iterators */

/* attributes */

}

private:
public:
this(char[] filename) {
}

~this() {
}

}

void process() {
int ret;
while (ret == 1) {
callback(this);
}
}

}

int main(char[][] args) {
printf("\nXML Demo\n\n");

/* This function will be called as each node is read */

/* slight language wart here, enums should be acceptable in a switch
expression imho */

break;
default: printf("\n"); break;

}

}