Print Color name of pixel hex value
<p>i have xml file containing colors name and hex values. I am trying to match xml file hex value with the hex value return by system using given code</p>

<pre><code> robot=new Robot();
 Point  coord = MouseInfo.getPointerInfo().getLocation(); 
 color = robot.getPixelColor((int)coord.getX(), (int)coord.getY());

 hexString = Integer.toHexString(color.getRGB());
 hexString = hexString.substring(2, hexString.length());
 hexString = hexString.toUpperCase(); 
</code></pre>

<p>but hex values of this code and stored in xml file never matches.. 
xml file has more than 2000 colors that's why i cant paste whole xml file here</p>

<pre><code>&lt;?xml version="1.0" standalone='no'?&gt;
&lt;!DOCTYPE ColorDefinition SYSTEM "color.dtd"&gt;

&lt;ColorDefinition&gt;
&lt;ColorSet id="VGA" language="English"&gt;

&lt;Property&gt;
&lt;description&gt;Choose a color name from 16 colors of VGA.&lt;/description&gt;
&lt;gray&gt;Gray&lt;/gray&gt;
&lt;/Property&gt;

&lt;color name="Black" rgb="000000"/&gt;
&lt;color name="White" rgb="ffffff"/&gt;
&lt;color name="Green" rgb="008000"/&gt;
&lt;color name="Silver" rgb="c0c0c0"/&gt;
&lt;color name="Lime" rgb="00ff00"/&gt;
&lt;color name="Gray" rgb="808080"/&gt;
&lt;color name="Olive" rgb="808000"/&gt;
&lt;color name="Yellow" rgb="ffff00"/&gt;
&lt;color name="Maroon" rgb="800000"/&gt;
&lt;color name="Navy" rgb="000080"/&gt;
&lt;color name="Red" rgb="ff0000"/&gt;
&lt;color name="Blue" rgb="0000ff"/&gt;
&lt;color name="Purple" rgb="800080"/&gt;
&lt;color name="Teal" rgb="008080"/&gt;
</code></pre>

<p>i dnt know what is the reason that why both hex values not matches....</p>

<p>code to read xml file and match both hex values (xml file hex value and hex value of pixel)</p>

<pre><code>        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        File file = new File("colore.xml");
        if (file.exists()) {
            Document doc = db.parse(file);
            Element docEle = doc.getDocumentElement();

            NodeList colorList = docEle.getElementsByTagName("color");

            if (colorList != null &amp;&amp; colorList.getLength() &gt; 0) {
                for (int i = 0; i &lt; colorList.getLength(); i++) {

                    Node node = colorList.item(i);                     

                    if (node.getNodeType() == Node.ELEMENT_NODE) {
                       NodeList mycolorList = doc.getElementsByTagName("color");
                        Element colorElement = (Element) mycolorList.item(i);

                        String colorName = colorElement.getAttribute("name");
                        String rgbvalue = colorElement.getAttribute("rgb");

                            if(rgbvalue.equalsIgnoreCase(hexString))
                            {
                               System.out.println("color name: " + colorName + " Hex: "      


                            }
                            else
                            {  
                                System.out.println("comparsion if statement not working 
                                                     here XML FIle HEX: "      
                                        + rgbvalue + " mouse click hex: " + hexString);            
                            }
</code></pre>

<p>now this else statement displays at output.... pixel hex values compares with each color in xml file (2222 colors) and display this above else statement 2222 times.. (if both hex values match then respective color name should be print in output...)</p>
