www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - onStartTag for root node in std.xml

In the test code, the onStartTag will not be called for the root node "set".

The onEndTag is OK, and the onStartTag is OK for sub nodes.

Is this a bug, or just it is? Can anybody confirm it?
Thanks.

// test.d
module main;

import std.string;
import std.stdio;
import std.xml;

int main(string[] argv)
{
	string s = r"<?xml version='1.0'?>
		<set>
		<one>A</one>
		<!-- comment -->
		<two>B</two>
		</set>";

	string tempStr;

	auto xml = new DocumentParser(s);

	xml.onStartTag["set"] = (ElementParser xml)
	{
		tempStr = "start=>" ~  xml.tag.name;
		writefln(tempStr);
		xml.parse();
	};

	xml.onEndTag["set"] = (in Element e)
	{
		tempStr = "end=>" ~ e.tag.name;
		writefln(tempStr);
	};

    xml.parse();

   return 0;
}
Dec 22 2011