Bug 17709 – std.xml doesn't parse the root element

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-08-01T00:24:42Z
Last change time
2021-02-07T13:24:17Z
Assigned to
No Owner
Creator
Mike Franklin

Comments

Comment #0 by slavo5150 — 2017-08-01T00:24:42Z
import std.xml; import std.stdio; void main() { auto parser = new DocumentParser("<?xml version=\"1.0\" encoding=\"utf-8\"?><device></device>"); parser.onStartTag["device"] = (ElementParser parser) { writeln("device"); }; parser.parse(); } That code does not print "device", However... import std.xml; import std.stdio; void main() { auto parser = new DocumentParser("<?xml version=\"1.0\" encoding=\"utf-8\"?><device><peripheral></peripheral></device>"); parser.onStartTag["peripheral"] = (ElementParser parser) { writeln("peripheral"); }; parser.parse(); } that code will print "peripheral".
Comment #1 by bugzilla — 2019-10-16T16:28:09Z
Seems to me, that the reason is, that the constructor of DocumentParser allready partially parses the xml document, namely until the root element is found. At that time parser.onStartTag["device"] is not yet defined and therefore not called. I don't understand std.xml good enough to fix this though. And the docs tell, that std.xml will be replaced by something better sooner or later. Therefore I don't know if it's worth it to fix this anyway.
Comment #2 by bugzilla — 2021-02-07T13:24:17Z
std.xml is deprecated since about a year. Closing this as WONTFIX.