package tools;

import org.w3c.dom.Element;
import org.w3c.dom.Node;


public class UserLogin {
	public String username ;
	public String password ;
	public String access ;
	
	public UserLogin(String username, String password, String access) {
		this.username = username ;
		this.password = password ;
		this.access = access ;
	}
	
	public UserLogin(Element element) {
		this.username = getValue(element.getElementsByTagName("username").item(0)) ;
		this.password = getValue(element.getElementsByTagName("password").item(0)) ;
		this.access = getValue(element.getElementsByTagName("access").item(0)) ;
	}
	
	public String getValue(Node node) {
		return node.getChildNodes().item(0).getNodeValue().trim() ;
	}

	public String toXML() {
		String xml = "\t<user>" ;
		xml += "\t\t<username>" + this.username + "</username>\n" ;
		xml += "\t\t<password>" + this.password + "</password>\n" ;
		xml += "\t\t<access>" + this.access + "</access>\n" ;
		xml += "\t</user>" ;
		return xml;
	}
}
