diff --git a/litexml.d b/litexml.d index ad0d983..4c0e794 100644 --- a/litexml.d +++ b/litexml.d @@ -140,6 +140,23 @@ class XmlNode } } + string text() + { + switch(type) + { + case XmlNodeType.Text: + return convertEntities(tag); + case XmlNodeType.Node: + case XmlNodeType.Root: + string childrenText; + foreach(child;children) + childrenText ~= child.text(); + return childrenText; + default: + return null; + } + } + final XmlNode findChild(string tag) { foreach(child;children) @@ -243,7 +260,7 @@ void skipWhitespace(Stream s) bool isWord(char c) { - return c=='-' || c=='_' || isalnum(c); + return c=='-' || c=='_' || c==':' || isalnum(c); } string readWord(Stream s) diff --git a/wp2git.d b/wp2git.d index 3316693..9ce91d3 100644 --- a/wp2git.d +++ b/wp2git.d @@ -26,11 +26,11 @@ int main(string[] args) foreach (child; xml[0]["page"]) if (child.tag=="revision") { - string summary = child["comment"].toString; - string text = child["text"].toString; + string summary = child["comment"] ? child["comment"].text : null; + string text = child["text"].text; data ~= "commit master\n" ~ - "committer <" ~ (child["contributor"]["username"] ? child["contributor"]["username"].toString : child["contributor"]["ip"].toString) ~ "> now\n" ~ + "committer <" ~ (child["contributor"]["username"] ? child["contributor"]["username"].text : child["contributor"]["ip"].text) ~ "> now\n" ~ "data " ~ .toString(summary.length) ~ "\n" ~ summary ~ "\n" ~ "M 644 inline " ~ name ~ ".txt\n" ~ @@ -38,6 +38,6 @@ int main(string[] args) text ~ "\n" ~ "\n"; } - write("fast-import-data", data); + return 0; }