SimpleXPathAPI & my app are different.
Here is my sample code. Pls let me know if there is anything wrong.
I am using xerces parser because I need to read/edit/create the XML documents
===================================================
XercesDOMParser* m_pXercesDOMParser;
DOMDocument* m_pDOMDocument;
XalanDocument* m_prefXalanDocument;
XPathEvaluator* m_pXPathEvaluator;
XercesDOMSupport* m_pXercesDOMSupport;
XercesParserLiaison* m_pXercesParserLiaison;
XalanDocumentPrefixResolver* m_pXalanDocumentPrefixResolver;
XercesDocumentWrapper* m_prefXercesDocumentWrapper;
XObject* prefXObject = 0;
m_pXmlFile = pFileName;
m_pXercesDOMParser = new xercesc::XercesDOMParser;
m_pXercesDOMParser->parse((const XMLCh*)m_pXmlFile.c_str());
m_pDOMDocument = m_pXercesDOMParser->getDocument();
m_prefXalanDocument =
m_pXercesParserLiaison->createDocument(m_pDOMDocument,0,1);
m_pXalanDocumentPrefixResolver
= new XalanDocumentPrefixResolver(m_prefXalanDocument);
m_prefXercesDocumentWrapper=m_pXercesParserLiais->mapDocumentToWrapper(m_prefXalanDocument);
m_pXalanContextNode =
m_pXPathEvaluator->selectSingleNode(*m_pXercesDOMSupport,m_prefXalanDocument,
"/catalog/book".c_str(),*m_pXalanDocumentPrefixResolver);
m_pXObjectPtr = new
XALAN_CPP_NAMESPACE::XObjectPtr((m_pXPathEvaluator->evaluate(
*m_pXercesDOMSupport,m_pXalanContextNode,
"child::[EMAIL PROTECTED]", *m_pXalanDocumentPrefixResolver)));
prefXObject = m_pXObjectPtr->get();
if(XObject::eObjectType::eTypeNodeSet == prefXObject->getType())
{
NodeRefList pTemp(prefXObject->nodeset());
iTempCount = pTemp.getLength();
// iTempCount is ZERO
}
===================================================
Thanks
Ramesh
On Sat, 4 Dec 2004 15:52:43 -0500, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> > ///XML file
> > <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> > <catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> > <book>
> > <author x="10">Adams</author>
> > <State>NC</State>
> > <subbook>
> > <genre>Computer</genre>
> > <price>44.95</price>
> > </subbook>
> > </book>
> > <secondAuthor>234</secondAuthor>
> > </catalog>
> > ////
> >
> > My XPath query is /catalog/book/child::[EMAIL PROTECTED]
> > evaluate() returns a NodeSet with 0 nodes in it.
>
> I ran your document with the sample program SimpleXPathAPI that ships with
> Xalan-C, and it found one node using your document and XPath expression. I
> don't know why your code is failing, but you might want to compare it to
> the sample code.
>
> >
> > I used "Visual XPath" and it returned 10.
>
> If "Visual XPath" returned 10 nodes evaluating that XPath expression with
> the exact document you've supplied then it has a bug. There are only 3
> child elements of "book", and there is only one with an attribute "x".
>
> Dave
>
--
~best~of~luck~
Ramesh Kumar