On 6/5/23 6:43 AM, Ferhat Kurtulmuş wrote:
On Monday, 5 June 2023 at 10:01:01 UTC, John Xu wrote:The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable?I need its detailed type (auto / Variant doesn't work).import dxml.dom; ?? xmlRoot; int main() { string xml = readText("a.xml"); auto dom = parseDOM(xml); xmlRoot = dom.children[0]; }```d import dxml.dom; import std.stdio; DOMEntity!string xmlRoot; int main() { string xml = "<some></some>"; auto dom = parseDOM(xml);writeln(typeof(dom.children[0]).stringof); // yields "DOMEntity!string"xmlRoot = dom.children[0]; return 0; } ```
In general, the easiset thing to do is use typeof, though it's not always pretty (and not always obvious how to write it). However, it's required for voldemort types.
```d
typeof(parseDom("")) DomEntity;
```
-Steve
