Welcome to SimpleXMLD
SimpleXMLD is an simple XML parser for D Programming Language inspired by PHP's SimpleXML, this libary could help you read XML file and traverse XML structure as an node tree in RAM.
It is suitable when your XML file is small, and you just want quickly access those data in XML easily.
Now it is just at alpha stage, it may be buggy, and any suggestion are welcome. You could use Forum to share your idea.
Here is a quick example shows the concept and usage of SimpleXMLD:
import SimpleXMLD.all;
void main ()
{
// Load XML from disk file.
SimpleXML root = SimpleXML.loadFile ("test.xml");
// Print out XML text constructed by SimpleXML objec tree.
Stdout (root.formattedXMLText);
// Iterate over all first level child
foreach (SimpleXML node; root) {
}
// Iterate over all first level child which XML tag is "tagname"
foreach (SimpleXML node; root["tagname"]) {
}
}
Supported Platform
It should be able compile and used under both GDC 0.24 with Tango under Linux and DMD 1.021 with Tango under Windows.
Requirement
You will need Tango and Mango to build this libary, since we use mango.xml as interanl XML file parser, instead of writng a new one.
DSSS also may help you install those libary mush easier.
Download
You may download current version (0.0.2) as ZIP archive or tar.gz archive.
You may also checkout the latest version from subversion:
svn co http://svn.dsource.org/projects/simplexmld/trunk
Or you just want quickly browse the source code, you could get it here.
API Documents
Installation
If you are already using Tango as your D runtime and had installed DSSS, please first install mango by typing following command at command line window:
dsss net install mango
When mango installtion is done, all you need to do is copy the SimpleXMLD folder in the libary archive to D's include folder where DSSS could find them.
Usage
If you installed DSS/Tango/Mango successfully, then it should be able to use SimpleXMLD now, just import SimpleXMLD. all .
// Filename: test.d
import SimpleXMLD.all;
void main ()
{
// Load XML from disk file.
SimpleXML root = SimpleXML.loadFile ("test.xml");
// Print out XML text constructed by SimpleXML objec tree.
Stdout (root.formattedXMLText);
// Iterate over all first level child
foreach (SimpleXML node; root) {
}
// Iterate over all first level child which XML tag is "tagname"
foreach (SimpleXML node; root["tagname"]) {
}
}
More examples could be found in SimpleXML API document.
Compile
If you already have DSSS/Tango/Mango, it should be very easy to compile source code that use SimpleXMLD, just follow normal dsss build process:
dsss build test.d
DSSS should compile and link your source code successfully now.
