
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;
/**
 *
 * @author adamhayes
 */
public class XMLParseDriver {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       //driver fnctn, read in message created by 
       //remote control, parse the info based on 
       //what we want
       
    }
    /*
        MAIN FUNCTION OF DRIVER
            purpose is to parse an XML message 
            sent by the remote control and separate out
            the 
    
    */
    public XMLMessage parseMessage(){
        XMLMessage parsed = new XMLMessage();
        return parsed;
    }
    
}

@@ -232,16 +232,298 @@
 args) %7B%0A
+        %0A        String xml = %22untitled.xml%22;%0A        XMLMessage data = parseMessage(xml);%0A        if(data == null)%7B%0A            System.out.println(%22Null returned by parsing.%22);%0A            System.exit(0);%0A        %7D%0A        System.out.println(data.getNum() + %22 %7C %22 + data.getID());%0A
        /
@@ -834,16 +834,23 @@
  public 
+static 
 XMLMessa
@@ -869,89 +869,2999 @@
 age(
-)%7B%0A        XMLMessage parsed = new XMLMessage();%0A        return parsed;%0A    %7D%0A    
+String fileName)%7B%0A        try%7B%0A            System.out.println(%22Checkpoint 1%22);%0A            DocumentBuilder builder = (DocumentBuilderFactory.newInstance()).newDocumentBuilder();%0A            System.out.println(%22Checkpoint 2%22);%0A            Document xml = builder.parse(fileName);%0A            Element root = xml.getDocumentElement();%0A            String%5B%5D values = findValues(root);%0A            %0A            System.out.println(%22Checkpoint 7%22);%0A            return new XMLMessage(values%5B0%5D, values%5B1%5D);%0A            %0A        %7Dcatch(Exception e)%7B%0A            System.out.println(%22There was an error while parsing the message%22);%0A            return null;%0A        %7D%0A    %7D%0A    private static Element findNode(Element el, String name)%7B%0A        NodeList nodes = el.getChildNodes();%0A        if(nodes != null)%7B%0A            for(int i = 0; i %3C nodes.getLength(); i++)%7B%0A                if(nodes.item(i).getNodeType() == Node.ELEMENT_NODE) %7B%0A                    Element e = (Element) nodes.item(i);%0A                    if(e.getNodeName().equals(name))%7B%0A                        return e;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D else %7B%0A            System.out.println(%22Specified element not found%22);%0A        %7D%0A        return null;%0A    %7D%0A  %0A    private static String%5B%5D findValues(Element root)%7B%0A        String%5B%5D keys = new String%5B2%5D;%0A        Element body = findNode(root, %22Body%22);%0A        System.out.println(%22STEP%22);%0A        NodeList items = body.getChildNodes();%0A        boolean phoneFound = false, idFound = false;%0A        System.out.println(%22STEP%22);%0A        if(items != null)%7B%0A            for(int i = 0; i %3C items.getLength(); i++)%7B%0A                System.out.println(%22STEP%22);%0A                if(items.item(i).getNodeType() == Node.ELEMENT_NODE)%7B%0A                    %0A                    Element e = (Element) items.item(i);%0A                    if(e.getNodeName().equals(%22Item%22))%7B%0A                        Node child;%0A                        NodeList children = e.getChildNodes();%0A                        for (int j = 0; j %3C children.getLength(); j++) %7B%0A                            child = children.item(j);%0A                            if(child.getTextContent().equals(%22VoterPhoneNo%22))%7B%0A                                System.out.println(%22PHONE%22);%0A                                keys%5B0%5D = children.item(j+2).getTextContent();%0A                                System.out.println(%22PHONE%22);%0A                                phoneFound = true;%0A                           %7D%0A                            if(child.getTextContent().equals(%22CandidateID%22))%7B%0A                                System.out.println(%22ID%22);%0A                                keys%5B1%5D = children.item(j+2).getTextContent();%0A                                System.out.println(%22ID%22);%0A                                idFound = true;%0A                           %7D%0A                        %7D%0A                        %0A                        %0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A       %0A       return keys;%0A    %7D
 %0A%7D%0A

Update XMLParseDriver.java