Is std.xml seriously broken, or is it me?

Mike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 29 20:16:35 PDT 2017


On Sunday, 30 July 2017 at 02:58:09 UTC, Mike wrote:

> 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();	
> }
>
> https://dpaste.dzfl.pl/262597d2fda6
>
> I used it before without any trouble.  Is it somehow seriously 
> broken?  If not, what am I doing wrong?

It appears `onStartTag` does not handle the root element.  For 
example, this code seems to work:

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();	
}

Mike



More information about the Digitalmars-d-learn mailing list