xpath/dom/term question
trying to get my head around a problem, not sure if there really is a solution, or a solution that's readily available. i'm trying to figure out if i can specify a "term" that's in the source of a webpage, and have the "blackbox" produce a fully qualified XPath for the DOM element that contains/has/uses the "term"
in other words, if i have a page, t开发者_高级运维hat has <a href="bbb" name='foo'>
, i'd like to be able to specify something like:
attribute="name
data="foo"
and the output would be the fully qualified XPath to get the <a/>
item
i'm looking for a the beginnings of a tool that would allow me to specify the specific elements of a webpage; the app/function would parse the DOM/page, build the tree, and then return the fully qualified XPath for the inputs..
i've looked/searched through various data on the net, with not much success...
UPDATE:: I'm not looking for a solution to create a single XPath, I'm looking for how to generalize this issue...
i can easily create an XPath for a given scenario... but i want to go the other way.
i want the "blackbox" to give me the "//...[@name="foo"]
so based on the inputs, the app would determine if the page has the element, and then generate the correct XPath for the DOM element...
in this manner, i might specify a form, and anchor, a whatever, and as long as i define the elementtype/id/name, the output would be the qualified XPath to then generate the data for the item/element.
hope that clarifies things a bit..
Try out XPather
In your query you specify something like: //*[@name="foo"]
, then you copy the full Xpath from the results window.
精彩评论