On Monday, 5 June 2023 at 10:43:27 UTC, 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;
    }
    ```

Thanks, that's very helpful. D sometimes drives me crazy, screws up my brain, :-)

Reply via email to