当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Extract element from html source code with xpath scripting

问题描述:

Here I have a some HTML code and I need to 1st. load url source code then type xpath and as a result get a some text from that URL based on xPath... How to do that... with jquery, ajax ... ???

http://jsfiddle.net/cHtWq/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

<body>

<label>Enter URL address here:

<input name="textfield" type="text" value="http://www." />

</label>

<label>

<input type="submit" name="Submit" value="Submit" />

<br />

<br />

Enter xpath location of element:

<input type="text" name="textfield2" />

<input type="submit" name="Submit2" value="Submit" />

<br />

<br />

Selected element is: </label>

<p>&nbsp;</p>

</body>

</html>

网友答案:

You cannot do this in JavaScript because of the Same Origin Policy you will need some back end scripting to do this.

分享给朋友:
您可能感兴趣的文章:
随机阅读: