www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - problem parsing xml (std.xml)

reply "Minas" <minas_mina1990 hotmail.co.uk> writes:
I'm trying to use std.xml to parse a small snippet of xml (for 
now).

This is my code:

[code]
void main(string[] args)
{
	string xmlText = "<?xml version=\"1.0\"?>\n" ~
					 "<book>" ~
					 "	Test" ~
					 "</book>";
	DocumentParser doc = new DocumentParser(xmlText);
	
	doc.onStartTag["book"] = (ElementParser el)
	{
		writeln("book opening found.");
	};
	
	doc.parse();
[/code]

My guess is that it would print "book opening found", but nothing 
is printed. I guess I made something wrong(?)
May 06 2012
parent "Stanislav Blinov" <stanislav.blinov gmail.com> writes:
Just a guess, but wouldn't <book> be the root node of the 
document, thus not qualifying for the onStartTag?
May 07 2012