PDA

View Full Version : Generating XPath query



Superstrength
4th November 2009, 18:48
Hi,

I am writing a tool which will automatically generate an XPath query for any URL on a web page. These queries will be passed to an another (already existing) tool that only understands XPath queries as its input, and unfortunately cannot be modified.

The tool I am writing is using QWebKit to render the web pages, and so far I can correctly identify any URL on the rendered web pages, which is a start. What I need now is for each URL identified to have the XPath query generated, which represents the URL location in that web page.

I've spent hours reading through the Qt docs, it seems I could find the URLs using XPath/XQuery if I know the document structure before-hand... but I need the opposite functionality. Also, this new tool could potentially be used on any webpage so the document structure will be variable.

Quiet frankly, I stumped on working out a solution on obtaining the XPath to specific content in an html document or XML document. So, could anyone kindly offer some pointers on how they have solved this problem before, please?

Many thanks, Terry.

PS: I'm using Qt 4.6.0 beta 1 if this makes any difference