EppGreeting * EppGreeting::fromXML( const DOM_Node &root )
{
	unsigned int i;
	EppGreeting * greeting = null;
	DOM_NodeList list = root.getChildNodes();
	for( i = 0; i < list.getLength(); i++ )
	{
		DOM_Node node = list.item(i);
		DOMString name = node.getLocalName();
		if( name == null )
		{
			name = node.getNodeName();
		}
		if( name == null )
		{
			continue;
		}
		if( name.equals("greeting") )
		{
			greeting = new EppGreeting();
			list = node.getChildNodes();
			break;
		}
	}

	if( greeting == null )
	{
		return null;
	}

	for( i = 0; i < list.getLength(); i++ )
	{
		DOM_Node node = list.item(i);
		DOMString name = node.getLocalName();
		if( name == null )
		{
			name = node.getNodeName();
		}
		if( name == null )
		{
			continue;
		}
		if( name.equals("svID") )
		{
			greeting->svID = EppUtil::getText(node);
		}
		else if( name.equals("svDate") )
		{
			greeting->svDate = EppUtil::getDate(node);
		}
		else if( name.equals("svcMenu") )
		{
			if( greeting->svcMenu != null )
			{
				delete greeting->svcMenu;
			}
			greeting->svcMenu = EppServiceMenu::fromXML(node);
		}
	}

	return greeting;
}
EppCommand * EppCommand::fromXML( const DOM_Node& root )
{
	unsigned int i;
	EppCommand * cmd = null;
	DOM_Node command;
	bool found = false;

	DOM_NodeList list = root.getChildNodes();
	for( i = 0; i < list.getLength(); i++ )
	{
		DOM_Node node = list.item(i);
		DOMString name = node.getLocalName();
		if( name == null )
		{
			name = node.getNodeName();
		}
		if( name == null )
		{
			continue;
		}
		if( name.equals("command") )
		{
			command = node;
			found = true;
			break;
		}
	}

	if( found == false )
	{
		return null;
	}

	list = command.getChildNodes();
	for( i = 0; i < list.getLength(); i++ )
	{
		DOM_Node node = list.item(i);
		DOMString name = node.getLocalName();
		if( name == null )
		{
			name = node.getNodeName();
		}
		if( name == null )
		{
			continue;
		}
		if( name.equals("login") )
		{
			cmd = EppCommandLogin::fromXML(node);
		}
		else if( name.equals("logout") )
		{
			cmd = EppCommandLogout::fromXML(node);
		}
		else if( name.equals("poll") )
		{
			cmd = EppCommandPoll::fromXML(node);
		}
		else if( name.equals("create") )
		{
			cmd = EppCommandCreate::fromXML(node);
		}
		else if( name.equals("delete") )
		{
			cmd = EppCommandDelete::fromXML(node);
		}
		else if( name.equals("info") )
		{
			cmd = EppCommandInfo::fromXML(node);
		}
		else if( name.equals("check") )
		{
			cmd = EppCommandCheck::fromXML(node);
		}
		else if( name.equals("renew") )
		{
			cmd = EppCommandRenew::fromXML(node);
		}
		else if( name.equals("transfer") )
		{
			cmd = EppCommandTransfer::fromXML(node);
		}
		else if( name.equals("update") )
		{
			cmd = EppCommandUpdate::fromXML(node);
		}
		/*
		 * other commands
		 */
		if( cmd != null )
		{
			break;
		}
	}
	if( cmd == null )
	{
		return null;
	}
	for( i = 0; i < list.getLength(); i++ )
	{
		DOM_Node node = list.item(i);
		DOMString name = node.getLocalName();
		if( name == null )
		{
			name = node.getNodeName();
		}
		if( name == null )
		{
			continue;
		}
		if( name.equals("creds") )
		{
			if( cmd->creds == null )
			{
				cmd->creds = EppCreds::fromXML(node);
			}
		}
		else if( name.equals("unspec") )
		{
			if( cmd->unspec == null )
			{
				cmd->unspec = EppUnspec::fromXML(node);
			}
		}
		else if( name.equals("clTRID") )
		{
			cmd->clTRID = EppUtil::getText(node);
		}
	}

	return cmd;
}