Tired, Exhausted, searched the web, usenets,forums thorughly but still
clueless. I guess it's time to post on the group :
This is the issue I have been trying to resolve since today morning :
I have an XHTML document in string form which I parse using Xerces
DOMParser (using an InputSource to read it).
Now I am trying to get to a node for which I have the Xpath, using the
XPathAPI.
So something like this :
Document doc = parser.getDocument(); // where parser is an instance
of DOMParser
Node onenode =
XPathAPI.selectSingleNode(doc,"html/body",doc.getDocumentElement());
I am using doc.getDocumentElement() as the namespace node because the
namespace is declared there - <html
xmlns="http://ww.w3.org/1999/xhtml">
The problem : selectSingleNode is always returning NULL.
I have tried almost everything. I saw somewhere on the groups that
somebody had set the Namespaceaware(boolean) to true for DomFactory but
I am not using DOMFactory. I am using DOMParser and I tried
setNamespaces(boolean) but it cannot find the method (I wonder why -
when it's a derived class from XMLParser).
Anyways, thats the problem I have been dealing with since today morning
(read as 8 hours).
If you have a solution, please help !
Thanks,
Anupam
anupamjain@gmail.com - 27 Mar 2006 17:25 GMT
I am still clueless about this. Can somebody please help me out?
- Anupam
> Tired, Exhausted, searched the web, usenets,forums thorughly but still
> clueless. I guess it's time to post on the group :
[quoted text clipped - 33 lines]
> Thanks,
> Anupam
anupamjain@gmail.com - 27 Mar 2006 17:27 GMT
Sorry, I was looking at the cached page I guess. Just saw the two
replies.
- Anupam
Chris Smith - 28 Mar 2006 07:16 GMT
> Document doc = parser.getDocument(); // where parser is an instance
> of DOMParser
> Node onenode =
> XPathAPI.selectSingleNode(doc,"html/body",doc.getDocumentElement());
I don't know this XPathAPI class very well. (Are you using Java 1.5?
If so, any reason you're not using XPath from the standard API?)
However, it looks like you're looking for a child of the document
element called "html". Rather, "html" IS the document element. Try
either of the following instead, and see one or both of them work
better.
XPathAPI.selectSingleNode(doc,"/html/body",doc.getDocumentElement());
XPathAPI.selectSingleNode(doc,"html/body",doc);

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation