Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Mark Reed
April 5, 2008, 4:02 pm
rate this thread
XHTML document successfully loaded into a DOMDocument object $doc
(although for some reason loadXML() complains that is not a
defined entity, even though the !DOCTYPE is pointing to an HTML DTD
that defines it). The document is navigable, with the DOM methods, I
can output it with saveXML() and all looks good, etc.
So I try to extract some nodes via XPath, and I can't find anything.
$xpath = new DOMXPath($doc);
$nodes = $xpath->query('//td');
That should find all the <td> elements. According to both $doc-
those. But it returns the empty set.
$xpath->query('/') returns the document node as expected.
$xpath->query('/*') returns the html element as expected.
$xpath->query('/html') returns the empty set.
$xpath->query('//html') also returns the empty set.
No matter what element name I use, XPath won't find it if I search for
it; but if I search via wildcards and then examine the name of the
nodes I find, they match exactly the strings I'm searching for.
None of the names are qualified in the document, btw.
So I'm a little confused.
Can anyone help?
Re: XPath help?
If I have this statement in my xhtml page:
<html xmlns=3D"http://www.w3.org/1999/xhtml " lang=3D""
then what would be my namespace? I don't know what I would have to
type inside the ->xpath() if I don't have a namespace declared (since
I don't want to change all my tags).
I hope you can help.
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — The site's Newest Thread. Posted in » Secure Shell Forum