McDonough, Michael wrote:
> While a valid html file, do you know whether it is a well-formed XML
> document?

Bradley, Martin wrote:
do you have a way to externally test the xpath expression into your html
doc?  I use Xselerator.  If you don't post the sample html and I can
verify the path is returning a nodelist.


Thanks for getting back to me... good idea. I used a prog called XmEdil which has an xpath tester (and tests the doc for validty and well-formednes when I open it). And, it seems I am doing something wrong with the xpath: when I select "/" I get the whole doc still, but when I put in any other xpath (//head, //p, etc.) I get no results.

Now, when I select "/", the xpath tester lists its result as being of type "document"... does this mean that I have to "get into" the document before my xpaths will work? I don't remember any such thing from my xpath/xsl class.

And actually, I already tried running the dom4j xpath methods after selecting the root node of the document:

        Element root = d.getRootElement();
        Node n = root.selectSingleNode("//p");

That doesn't work either. :-(
        
Anyway, here's the html... hope you guys have more ideas.

Thanks,

Ben

PS: Just noticed that the xpath builder window has a tab called "nodes" which shows a list of the elements and attributes in my doc (p, div, a, class, etc). So, it's even figuring out that there are sub nodes within this "document" element... but I can't select them with xpaths!?

-------------------------------------------------

Using this as test doc:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>


<html>
<head>
<title>
test page
</title>
</head>
<body>
<div class="navbox">
<p>
SITE LINKS:
</p>
<a href="#">A link</a><br />
<a href="#">A link again</a><br />
<a href="#">Another link</a><br />
<a href="#">A link too</a><br />
</div>
<div class="content">
<h1>
Test page!
</h1>
<p>
Lobore et dolore nagna aliquam erat volupat. At enim ad minimin veniami quis nostrud
exercitation lorem ipsum dolor sit amet, consectetur adips cing elit, diam nonnumy
eiusmod tempor incidunt ut ullamcorper suscripit laboris nisi ut alquip exea commodo
consequat, consectetur adips cing elit.
</p>
</div>
</body>
</html>







------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to