import java.util.*; class Tag { HashMap nvpairs; HashMap childTags; public Tag() { nvpairs=new HashMap(); childTags=new HashMap(); } public void addTag(String tname,Tag t) { childTags.put(tname,t); } } class HRMLParser { Tag root; Stack tagStack; public HRMLParser() { root=new Tag(); tagStack=new Stack(); tagStack.push(root); } public void parseLine(String line) { //Format --> line=line.substring(1,line.length()-1); //Strip < > if(line.charAt(0)!='/')//If starting tag { int firstSpace=line.indexOf(" "); String tagName; Tag newTag=new Tag(); if(firstSpace>0) { tagName=line.substring(0,firstSpace); line+=" "; String[] nvs=line.substring(firstSpace+1,line.length()).split("\" "); String name,value; String[] pair; for(int i=0;iattribute_x , "value_x ] name=pair[0].trim(); // attribute_x --> attribute_x value=pair[1].trim(); // "value_x --> "value_x value=value.substring(1); // Remove leading quote "value_x--> value_x //System.out.println(name+"="+value); newTag.nvpairs.put(name,value); } } else tagName=line; Tag parent=tagStack.peek(); parent.addTag(tagName,newTag); tagStack.push(newTag); System.out.println(tagName); } else tagStack.pop(); } public void eval(String str) { String[] tagInfo=str.split("\\."); Tag currentTag=root; if(tagInfo.length>0) { String[] reqTag=tagInfo[tagInfo.length-1].split("~"); //System.out.println(tagInfo[tagInfo.length-1]); for(int i=0;i