title: How to identify the DOM node proximity
body: <p>Lets say I have a set of nodes A,B,C,D and a node say X. Now I need to find the proximity of A,B,C,D with respect to node X. (Using Java)</p>
  
  <p>So that I can get to know which of the node from the given set of nodes is nearest to node X.</p>
  
  <p><strong>EDIT :</strong>
   Let say, a HTML has a node called DOB (Node X). I have <em>regex</em> pattern [0-9]{2}/[0-9]{2}/[0-9]{4} for that Node DOB, to represent the value of DOB which will possibly in text node. Now I will search given HTML DOM to look for the text node which satisfies the <em>regex</em> pattern.  </p>
  
  <p>Now the nodes which satisfies the pattern will be more than one.Assume there is a <em>Account Opening Date</em>,*RepairDate* nodes are there in the HTML.So there will be three text nodes which will be satisfying the pattern.Now I need to identify which of the three text nodes is corresponds to Node DOB?</p>