Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

how to get the position of fields

Help
Virg g
2009-01-29
2013-04-29
  • Virg g
    Virg g
    2009-01-29

    Hi,
    I am doing only HTML parsing for locating the field elements with in a web page from form tag. I trying to find the complete path of a form element example Input Text fields from its Form tag. I am using ancestor function to get the complete path.  example ancestor function returns the path for input text field is

    "form table tr td input"

    But i want is positions of these elements  in the path with respect to its parent like

    "form table[1] tr[1] td[2] input".

    like first table from from and 1st tr from the table and 2nd td from tr so on..
    If it is not possible to get the complete path with positions atleast
    Is there any way to get the position of element without looping through all the elements of a node.

    Any help is hightly appreciated

    Thanks in advance

    Virg

     
    • Arjan Somers
      Arjan Somers
      2009-01-29

      The w3c implementation of Node does not have a method to get a unique path.

      The simplest thing to do is probably to write your own getUniquePath() function as suggested on this site:

      http://bytes.com/groups/net-xml/179819-xpathnavigator-getuniquepath

       
    • Virg g
      Virg g
      2009-01-30

      Thank you very much. It meets my requirement.