XML Parsing
Iain
staffell at gmail.com
Fri May 18 16:08:58 PDT 2012
On Tuesday, 20 March 2012 at 04:32:13 UTC, Adam D. Ruppe wrote:
> I know very little about std.xml (I looked at it and
> said 'meh' and wrote my own lib), but my lib
> makes this pretty simple.
>
> https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
>
> grab dom.d and characterencodings.d
>
> This has a bit of an html bias, but it works for xml too.
>
> ===
> import arsd.dom;
> import std.file;
> import std.stdio;
> import std.conv;
>
> void main() {
> auto document = new Document(readText("test12.xml"), true,
> true);
>
> auto map = document.requireSelector("map");
>
> writeln(to!int(map.width), "x", to!int(map.height));
>
> foreach(tile; document.getElementsByTagName("tile"))
> writeln(tile.gid);
> }
> ===
>
> $ dmd test12.d dom.d characterencodings.d
> $ test12
> 25x19
> <snip tile data>
>
Hi Adam,
I'm also interested in your solution, as the std.xml page is so
sparsely documented I can't make head nor tail of it. Also,
neither of the examples compile for me, making life that little
bit harder!
Sadly, I can't get your code working either! I have downloaded
the folder zip from your github link, and extracted it so that
all the .d files are living in C:\D\dmd2\src\phobos\arsd\
If I try to compile the code you gave above, I get a pile of
linking errors using D 2.059:
C:\D\dmd2\windows\bin\dmd.exe parseSpain -O
OPTLINK (R) for Win32 Release 8.00.12
Copyright (C) Digital Mars 1989-2010 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
parseSpain.obj(parseSpain)
Error 42: Symbol Undefined _D4arsd3dom12__ModuleInfoZ
parseSpain.obj(parseSpain)
Error 42: Symbol Undefined _D4arsd3dom8__assertFiZv
parseSpain.obj(parseSpain)
Error 42: Symbol Undefined
_D4arsd3dom24ElementNotFoundException7__ClassZ
parseSpain.obj(parseSpain)
Error 42: Symbol Undefined
_D4arsd3dom24ElementNotFoundException6__ctorMFAyaAya
AyaiZC4arsd3dom24ElementNotFoundException
parseSpain.obj(parseSpain)
Error 42: Symbol Undefined
_D4arsd3dom8Document6__ctorMFAyabbZC4arsd3dom8Docume
nt
parseSpain.obj(parseSpain)
Error 42: Symbol Undefined _D4arsd3dom8Document7__ClassZ
--- errorlevel 6
Do you have any idea what's going on?!
More information about the Digitalmars-d-learn
mailing list