Menu

Getting XPath of an element

2012-12-24
2012-12-26
  • Arjun Raman

    Arjun Raman - 2012-12-24

    Hi,

    Is it possible to get the XPath of an element from a Page? Is it supported?

    Thanks,
    Arjun

     
  • Arjun Raman

    Arjun Raman - 2012-12-24

    Or would it be possible to get the CSS Expression of the selected element?

    I'm building a tool similar to firebug. I need to figure out a way to get either the XPath or the CSS Selector of the selected element.

    Thanks,
    Arjun

     
  • Radek Burget

    Radek Burget - 2012-12-26

    For obtaining the style of an ElementBox, you may use its getStyle() (object representation) or getStyleString() (a CSS string representation) functions. You may check the BoxBrowser.java demo that shows the details about a displayed box when you click it.

    For examining the DOM tree, you may use the ElementBox getElement() function and then use standard DOM functions (e.g. getParent() etc.) Again, the BoxBrowser demo shows the DOM tree in the second tab in the left column.

    I am not sure what excatly you would like to use XPath for. CSSBox does not include an XPath processor however it works with a standard DOM. That means, you may use any third-party XPath processor when necessary.

    Radek

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.