开发者

How to choose with xpath script in html head?

How to choose with xpath script in html head?

Example(How to choose only ThisFile1.js?):

<html>
<head>
<script type="text/javascript" src="ThisFile1.js"></script>
</head>
<body>
<script type="text/javascript" src="NotThisFile1.js"></script>
<script type="text/javascript" src开发者_开发问答="NotThisFile2.js"></script>
<script type="text/javascript" src="NotThisFile3.js"></script>
<script type="text/javascript" src="NotThisFile4.js"></script>
</body>
</html>

Thanks, Yosef


Use:

/*/head/script/@src

or

string(/*/head/script/@src)

The first XPath expression selects all src attributes of all script elements that are childtren of all head elements that are children of the top element in the XML document.

The second XPath expression evaluates to the string value of the first of the attributes, selected by the first XPath expression. This would be most convenient if your XPath engine's API provides support for evaluting XPath expression that do not select nodes. If this is not the case you have to use the first XPath expression, then use the appropriate method/property of the API that returns the string value of the selected attribute node.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜