I can only parse one row successfully. I tried increasing the popFronts, till it said I'd gone off the end.

Running ./app
core.exception.AssertError@../../../../.dub/packages/dxml-0.4.1/dxml/source/dxml/parser.d(1457):
 text cannot be called with elementEnd
----------------
??:? _d_assert_msg [0x104b3981a]
../../JMiscLib/source/jmisc/base.d:161 pure @property @safe immutable(char)[] dxml.parser.EntityRange!(dxml.parser.Config(1, 1, 1, 1), immutable(char)[]).EntityRange.Entity.text() [0x104b2297b]
source/app.d:26 _Dmain [0x104aeb46e]
Program exited with code 1

```
<?xml version="1.0"?>

<resultset statement="SELECT * FROM bible.t_asv
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <row>
        <field name="id">01001001</field>
        <field name="b">1</field>
        <field name="c">1</field>
        <field name="v">1</field>
<field name="t">In the beginning God created the heavens and the earth.</field>
  </row>

  <row>
        <field name="id">01001002</field>
        <field name="b">1</field>
        <field name="c">1</field>
        <field name="v">2</field>
<field name="t">And the earth was waste and void; and darkness was upon the face of the deep: and the Spirit of God moved upon the face of the waters.</field>
  </row>

```

```d
void main() {
    import std.stdio;
    import std.file : readText;
    import dxml.parser;
    import std.conv : to;

    struct Verse {
        string id;
        int b, c, v;
        string t;
    }

    auto range = parseXML!simpleXML(readText("xmltest.xml"));

    // simpleXML skips comments

    void pops(int c) {
        foreach(_; 0 .. c)
            range.popFront();
    }
    pops(3);

    Verse[] vers;
    foreach(_; 0 .. 2) {
        Verse ver;
        ver.id = range.front.text;
        pops(3);
        ver.b = range.front.text.to!int;
        pops(3);
        ver.c = range.front.text.to!int;
        pops(3);
        ver.v = range.front.text.to!int;
        pops(3);
        ver.t = range.front.text;

        with(ver)
            vers ~= Verse(id,b,c,v,t);

        pops(2);
    }
    foreach(verse; vers) with(verse)
        writeln(id, " Book: ", b, " ", c, ":", v, " -> ", t);
}
```

Reply via email to