www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What xml libraries are people using?

reply "simendsjo" <simendsjo gmail.com> writes:
Everyone says "Don't use std.xml", and there are several other 
libraries.
Which can you recommend? (I haven't looked closely at any of 
them, just some links found by googling)

https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d
http://svn.dsource.org/projects/xmlp/trunk/std/
https://github.com/theredhead/red.xml
https://github.com/opticron/kxml
https://github.com/opticron/libdxml2
https://launchpad.net/d2-xml
Mar 02 2013
next sibling parent "Dicebot" <m.strashun gmail.com> writes:
On Saturday, 2 March 2013 at 08:03:08 UTC, simendsjo wrote:
 Everyone says "Don't use std.xml", and there are several other 
 libraries.
 Which can you recommend? (I haven't looked closely at any of 
 them, just some links found by googling)

 https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d
 http://svn.dsource.org/projects/xmlp/trunk/std/
 https://github.com/theredhead/red.xml
 https://github.com/opticron/kxml
 https://github.com/opticron/libdxml2
 https://launchpad.net/d2-xml
http://wiki.dlang.org/Review_Queue notice std.xml2 there and its "ready for comments"
Mar 02 2013
prev sibling next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
I use the dom.d in the long misc github link. (I wrote it for 
myself)

I find it very convenient but there are some downsides:

1) it is slow with large files
2) it eats a lot of memory, I think about 150 bytes per node, 
plus the actual data (text and attributes). A 1 MB xml file can 
easily eat 10 MB of ram.
3) it isn't very well documented, but if you've used javascript 
dom, most your knowledge can carry over.


So if you're working with a lot of data, you don't want to use it.

But if you're using smaller files and want a lot of convenience 
with stuff like css selectors and convenience functions, or want 
to deal with poorly written html, it is something you can try.

It requires the files dom.d and characterencodings.d from my 
github.


To parse xml while checking for well formedness and utf-8:

auto document = new Document();
document.parse(strXml, true, true);

To parse html while correcting for tags soup and wrong character 
encodings:

auto document = new Document();
document.parseGarbage(strHtml);
Mar 02 2013
parent Russel Winder <russel winder.org.uk> writes:
I don't do XML working with D, but with Python. Actually I'd prefer
never to have to work with XML at all but,=E2=80=A6

After many different Python oriented (either Python implemented or C
coded Python extensions), the tide has now turned to simply using
libxml2 and libxslt using an adaptor library, lxml.

I am assuming if I did do XML work in D, I would connect to these same
libraries just as Python does.

--=20
Russel.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.n=
et
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Mar 02 2013
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2013-03-02 09:03, simendsjo wrote:
 Everyone says "Don't use std.xml", and there are several other libraries.
 Which can you recommend? (I haven't looked closely at any of them, just
 some links found by googling)

 https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d

 http://svn.dsource.org/projects/xmlp/trunk/std/
 https://github.com/theredhead/red.xml
 https://github.com/opticron/kxml
 https://github.com/opticron/libdxml2
 https://launchpad.net/d2-xml
The one in Tango: Docs: http://dsource.org/projects/tango/docs/current/ Tango-D2: https://github.com/SiegeLord/Tango-D2 It's damn fast. -- /Jacob Carlborg
Mar 02 2013
prev sibling next sibling parent reply "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Saturday, 2 March 2013 at 08:03:08 UTC, simendsjo wrote:
 Everyone says "Don't use std.xml", and there are several other 
 libraries.
 Which can you recommend? (I haven't looked closely at any of 
 them, just some links found by googling)

 https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d
 http://svn.dsource.org/projects/xmlp/trunk/std/
 https://github.com/theredhead/red.xml
 https://github.com/opticron/kxml
 https://github.com/opticron/libdxml2
 https://launchpad.net/d2-xml
I use xmlp, aka d2-xml, aka std.xml2 on Review Queue http://wiki.dlang.org/Review_Queue Source: https://launchpad.net/d2-xml XML is pretty complex so I hope more people try and use so that we can get a nice library into Phobos that will appeal to most people. I don't see Michael Rynn too much on the forms, but he's been pretty receptive when I email him.
Mar 02 2013
parent reply Brad Roberts <braddr slice-2.puremagic.com> writes:
On Sat, 2 Mar 2013, Jesse Phillips wrote:
 On Saturday, 2 March 2013 at 08:03:08 UTC, simendsjo wrote:
 Everyone says "Don't use std.xml", and there are several other libraries.
 Which can you recommend? (I haven't looked closely at any of them, just some
 links found by googling)
 
 https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d
 http://svn.dsource.org/projects/xmlp/trunk/std/
 https://github.com/theredhead/red.xml
 https://github.com/opticron/kxml
 https://github.com/opticron/libdxml2
 https://launchpad.net/d2-xml
I use xmlp, aka d2-xml, aka std.xml2 on Review Queue http://wiki.dlang.org/Review_Queue Source: https://launchpad.net/d2-xml XML is pretty complex so I hope more people try and use so that we can get a nice library into Phobos that will appeal to most people. I don't see Michael Rynn too much on the forms, but he's been pretty receptive when I email him.
Has this implementation been bounced off the w3c xml test suite?
Mar 03 2013
parent "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Monday, 4 March 2013 at 04:45:45 UTC, Brad Roberts wrote:

 Has this implementation been bounced off the w3c xml test suite?
I don't know, but the xml tests don't seem to be the those provided by W3C http://bazaar.launchpad.net/~michael-rynn-500/d2-xml/d2-xml-dev/files/head:/test/xmltest/
Mar 05 2013
prev sibling next sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 3/2/13, simendsjo <simendsjo gmail.com> wrote:
 Which can you recommend?
I use ae's lite xml library: https://github.com/CyberShadow/ae/blob/master/utils/xmllite.d It's not a monster but thanks to UFCS I can easily extend it to do what I want. For some trivial xml parsing which I needed it was great (OTOH std.xml is a segfaulting monster).
Mar 02 2013
next sibling parent "timotheecour" <thelastmammoth gmail.com> writes:
On Saturday, 2 March 2013 at 18:42:13 UTC, Andrej Mitrovic wrote:
 On 3/2/13, simendsjo <simendsjo gmail.com> wrote:
 Which can you recommend?
I use ae's lite xml library: https://github.com/CyberShadow/ae/blob/master/utils/xmllite.d It's not a monster but thanks to UFCS I can easily extend it to do what I want. For some trivial xml parsing which I needed it was great (OTOH std.xml is a segfaulting monster).
I've used xmlparser, "a lightweight C++ library for parsing xml files", which was indeed fast and lightweight. http://vipbase.net/xmlparser/ someone would need to port it to D though, but shouldn't be too hard as the library is indeed small.
Mar 03 2013
prev sibling parent "Gary Willoughby" <dev kalekold.net> writes:
On Saturday, 2 March 2013 at 18:42:13 UTC, Andrej Mitrovic wrote:
 On 3/2/13, simendsjo <simendsjo gmail.com> wrote:
 Which can you recommend?
I use ae's lite xml library: https://github.com/CyberShadow/ae/blob/master/utils/xmllite.d It's not a monster but thanks to UFCS I can easily extend it to do what I want. For some trivial xml parsing which I needed it was great (OTOH std.xml is a segfaulting monster).
Has anyone got any examples of using this library? Reading nodes, attributes etc.
May 24 2013
prev sibling next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
	charset=iso-8859-1

I've used xmlparser, "a lightweight C++ library for parsing xml files", =
which was indeed fast and lightweight.=20
http://vipbase.net/xmlparser/
someone would need to port it to D though, but shouldn't be too hard as =
the library is indeed small.=20


On Mar 2, 2013, at 10:42 AM, Andrej Mitrovic =
<andrej.mitrovich gmail.com> wrote:

 On 3/2/13, simendsjo <simendsjo gmail.com> wrote:
 Which can you recommend?
=20 I use ae's lite xml library: =20 https://github.com/CyberShadow/ae/blob/master/utils/xmllite.d =20 It's not a monster but thanks to UFCS I can easily extend it to do what I want. For some trivial xml parsing which I needed it was great (OTOH std.xml is a segfaulting monster).
Mar 03 2013
prev sibling parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 02.03.2013 09:03, schrieb simendsjo:
 Everyone says "Don't use std.xml", and there are several other libraries.
 Which can you recommend? (I haven't looked closely at any of them, just
 some links found by googling)

 https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d

 http://svn.dsource.org/projects/xmlp/trunk/std/
 https://github.com/theredhead/red.xml
 https://github.com/opticron/kxml
 https://github.com/opticron/libdxml2
 https://launchpad.net/d2-xml
I'm using a port of tinyxml I did myself: https://github.com/Ingrater/thBase/blob/master/src/thBase/tinyxml.d Kind Regards Benjamin Thaut
May 24 2013