parsing - Confused about std.xml - how do I read attributes? -
I have thrown together an XML control file for a command-line tool, which I use to manage my compiler My goal is to use this XML file to basically use a code like compile d -release foo.d
to open it, process it to create Dmd -m64 -O -inline -release - Noboundscheck foo.d
and execute it. I've redesigned the XML file here for clarity:
& lt; Compilers & gt; & Lt; Compiler id = "d" & gt; & Lt; Command & gt; "Dmd -m64" & lt; / Command & gt; & Lt; Mode & gt; & Lt; Mode id = "- debug" & gt; "- debug-unit-w -de" & lt; / Mode & gt; & Lt; Mode id = "- release" & gt; "-Olline -Release -Nobbed Check" & lt; / Mode & gt; & Lt; / Mode & gt; & Lt; / Compiler & gt; & Lt; Compiler id = "java" & gt; & Lt; Order & gt; "Javac" & lt; / Order & gt; & Lt; Mode & gt; & Lt; Mode id = "- debug" & gt; "-G-Xlint" & lt; / Mode & gt; & Lt; / Mode & gt; & Lt; / Compiler & gt;
Now, by reading std.xml
, I have to do something like this:
Import Do std.xml, std.stdio, std.string, std.file; Zero main (string [] args) {auto from_command_line = someFunctionThatDealsWithInput (args); String s = artist (string) std.file.read ("path / to / xml / file.xml"); Czech (s); Auto parse = documentpress (s); // in any way, to create a valid command line command, with XML, it sends it to the shell)
I know how to execute the stuff in the shell, But I'm not sure how to use the XML document using the std.xml
API, I'm not sure how to get the contents of the node's properties (but To be honest, the whole thing is very much for me Does not hold).
Can I suggest KXML instead? I find it very easy to parse XML (especially with Bistin Xpith).
Comments
Post a Comment