We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From @NVolcz on October 18, 2016 21:24
unittest { import std.experimental.xml.lexers; import std.experimental.xml.parser; import std.string : lineSplitter, strip; import std.algorithm : map; import std.array : array; wstring xml = q{ <?xml encoding = "utf-8" ?> <!DOCTYPE mydoc> <aaa> <works> test </works> <notWork></notWork> </aaa> }; auto cursor = xml.lexer.parser.cursor; assert(cursor.atBeginning); // <?xml encoding = "utf-8" ?> assert(cursor.kind() == XMLKind.document); assert(cursor.name() == "xml"); assert(cursor.prefix() == ""); assert(cursor.localName() == "xml"); assert(cursor.attributes().array == [Attribute!wstring("encoding", "utf-8")]); assert(cursor.content() == " encoding = \"utf-8\" "); assert(cursor.enter()); assert(!cursor.atBeginning); // <!DOCTYPE mydoc assert(cursor.kind == XMLKind.dtdEmpty); assert(cursor.wholeContent == " mydoc"); assert(cursor.next); // <aaa> assert(cursor.kind() == XMLKind.elementStart); assert(cursor.name() == "aaa"); assert(cursor.prefix() == ""); assert(cursor.localName() == "aaa"); assert(cursor.enter()); // <works> assert(cursor.kind() == XMLKind.elementStart); assert(cursor.name() == "works"); assert(cursor.enter()); assert(!cursor.enter()); assert(!cursor.next()); //cursor.exit(); // </works> assert(cursor.kind() == XMLKind.elementEnd); assert(cursor.name() == "works"); cursor.exit(); assert(cursor.next()); // <notWork> assert(cursor.kind() == XMLKind.elementStart); assert(cursor.name() == "notWork"); assert(!cursor.enter()); assert(!cursor.next()); // </notWork> assert(cursor.kind() == XMLKind.elementEnd); assert(cursor.name() == "notWork"); assert(!cursor.next()); cursor.exit(); // </aaa> assert(cursor.kind() == XMLKind.elementEnd); assert(cursor.name() == "aaa"); assert(!cursor.next()); cursor.exit(); assert(cursor.documentEnd); assert(!cursor.atBeginning); }
Copied from original issue: lodo1995/experimental.xml#34
The text was updated successfully, but these errors were encountered:
No branches or pull requests
From @NVolcz on October 18, 2016 21:24
Copied from original issue: lodo1995/experimental.xml#34
The text was updated successfully, but these errors were encountered: